]> git.bitcoin.ninja Git - rust-lightning/commit
Ensure we read the full TLV stream length when maybe-reading `None`
authorMatt Corallo <git@bluematt.me>
Thu, 28 Mar 2024 22:02:09 +0000 (22:02 +0000)
committerMatt Corallo <git@bluematt.me>
Sun, 7 Apr 2024 19:55:56 +0000 (19:55 +0000)
commitd6770d4a74348c91c91dfe734a1c38b7fa26d81e
tree74009a1140f7cc54ea45c74563b66e63fe213641
parentcc78b77c715d6ef62693d4c1bc7190da990ec0fa
Ensure we read the full TLV stream length when maybe-reading `None`

If we are reading an object that is `MaybeReadable` in a TLV stream
using `upgradable_required`, it may return early with `Ok(None)`.
In this case, it will not read any further TLVs from the TLV
stream. This is fine, except that we generally expect
`MaybeReadable` always consume the correct number of bytes for the
full object, even if it doesn't understand it.

This could pose a problem, for example, in cases where we're
reading a TLV-stream `MaybeReadable` object inside another
TLV-stream object. In that case, the `MaybeReadable` object may
return `Ok(None)` and not consume all the available bytes, causing
the outer TLV read to fail as the TLV length does not match.
lightning/src/lib.rs
lightning/src/util/ser_macros.rs