1
0
Fork 0
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:
Rusty Russell 2019-07-09 20:30:16 +09:30
parent 6af2ba23a8
commit f3fb4ec9c4

View file

@ -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`.