mirror of
https://github.com/lightning/bolts.git
synced 2025-03-10 09:10:07 +01:00
BOLT 1: explicitly disallow trailing data, require minimal values.
We didn't explicitly say that the TLV is bad if length exceeds the message length! We didn't specify whether to ignore extra bytes: we should. Similarly, contents of values must be minimal (i.e. tu64 etc). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
6af2ba23a8
commit
f3fb4ec9c4
1 changed files with 6 additions and 0 deletions
|
@ -129,8 +129,14 @@ The receiving node:
|
||||||
- MUST fail to parse the `tlv_stream`.
|
- MUST fail to parse the `tlv_stream`.
|
||||||
- if decoded `type`s are not monotonically-increasing:
|
- if decoded `type`s are not monotonically-increasing:
|
||||||
- MUST fail to parse the `tlv_stream`.
|
- MUST fail to parse the `tlv_stream`.
|
||||||
|
- if `length` exceeds the number of bytes remaining in the message:
|
||||||
|
- MUST fail to parse the `tlv_stream`.
|
||||||
- if `type` is known:
|
- if `type` is known:
|
||||||
- MUST decode the next `length` bytes using the known encoding for `type`.
|
- MUST decode the next `length` bytes using the known encoding for `type`.
|
||||||
|
- if `length` is not exactly equal to that required for the known encoding for `type`:
|
||||||
|
- MUST fail to parse the `tlv_stream`.
|
||||||
|
- if variable-length fields within the known encoding for `type` are not minimal:
|
||||||
|
- MUST fail to parse the `tlv_stream`.
|
||||||
- otherwise, if `type` is unknown:
|
- otherwise, if `type` is unknown:
|
||||||
- if `type` is even:
|
- if `type` is even:
|
||||||
- MUST fail to parse the `tlv_stream`.
|
- MUST fail to parse the `tlv_stream`.
|
||||||
|
|
Loading…
Add table
Reference in a new issue