graph/db: validate edge policy TLV data before persisting
In this commit, we start validating the extra opaque data of a channel edge policy before persisting it. We just check that the data is valid TLV. NOTE: we recently [started validating](https://github.com/lightningnetwork/lnd/commit/1410a0949d555e14de11faf81a17fe64917505e3) this at the lnwire level. So really, no new update will reach the DB layer without this already being checked. But we check it again here so that the DB API behaves correctly as its own unit.
This commit is contained in:
3 files changed
+22
-6
No files matched your search
@@ -4546,6 +4546,12 @@ func serializeChanEdgePolicy(w io.Writer, edge *models.ChannelEdgePolicy,
|
||||
}
|
||||
}
|
||||
|
||||
// Validate that the ExtraOpaqueData is in fact a valid TLV stream.
|
||||
err = edge.ExtraOpaqueData.ValidateTLV()
|
||||
if err != nil {
|
||||
return fmt.Errorf("%w: %w", ErrParsingExtraTLVBytes, err)
|
||||
}
|
||||
|
||||
if len(edge.ExtraOpaqueData) > MaxAllowedExtraOpaqueBytes {
|
||||
return ErrTooManyExtraOpaqueBytes(len(edge.ExtraOpaqueData))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user