backport: consensus: Add CompactSize range check to deserialization#5921
Conversation
|
I've noticed these changes were applied on master in #5697, I should have commented there first. |
|
Wait -- will this break PSBT on 0.32.x? Otherwise utack 88722b0 |
|
PSBT on 0.32.x is borked anyways if anyone uses a key |
|
@apoelstra I update to latest nightly and we get a single lint warning but this code is the same on Using at nightly-version ✘ 101
nightly-2026-03-27error: value assigned to `w` is never read
--> hashes/src/sha256.rs:235:13
|
235 | $w = updates.2;
| ^^^^^^^^^^^^^^
...
803 | round!(b, c, d, e, f, g, h, a, 0xc67178f2, w[15], w[13], w[8], w[0]);
| -------------------------------------------------------------------- in this macro invocation
|
= help: maybe it is overwritten before being read?
= note: `-D unused-assignments` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(unused_assignments)]`
= note: this error originates in the macro `round` (in Nightly builds, run with -Z macro-backtrace for more info)
error: value assigned to `w` is never read
--> hashes/src/sha512.rs:167:13
|
167 | $w = small_hash::later_round($a, $b, $c, &mut $d, $e, $f, $g, &mut $h, $k, $w, $w1, $w2, $w3)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
293 | round!(b, c, d, e, f, g, h, a, 0x6c44198c4a475817, w[15], w[13], w[8], w[0]);
| ---------------------------------------------------------------------------- in this macro invocation
|
= help: maybe it is overwritten before being read?
= note: this error originates in the macro `round` (in Nightly builds, run with -Z macro-backtrace for more info)
error: could not compile `bitcoin_hashes` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: could not compile `bitcoin_hashes` (lib test) due to 2 previous errors
error: Recipe `lint` failed on line 14 with exit code 101 |
|
@tcharding we have a macro We should just whitelist the lint on any blocks that are affected. |
|
Thanks. What confused me was why the lint fires here but not on master? I looked again and I'm guessing, but its not clear, and probably not important, because we use I wrote up: #5957 |
I'm pretty sure we whitelisted it |
|
in #5376 |
88722b0 to
8a8498f
Compare
|
Nice digging. I added the patch from #5376 to this. I just cherry-picked it, the commit log is a bit odd now. You ok with that? |
8a8498f to
e760a5d
Compare
|
@tcharding can you put a patch at the front of this which updates the nightly version? |
80f688b to
829981b
Compare
|
Squashed all the lint fixes into the 'update nightly toolchain' patch. I forget, do you run the linter on each patch? |
829981b to
5c76a41
Compare
I do not -- but I do attempt to use the nightly compiler on each patch. So I cannot test this PR unless the first commit fixes the nightly-version file. |
Copy the version currently on master and fix the introduced lint warnings.
Manually backport rust-bitcoin#5697. On `master` the `VarInt` type is gone but the deserialization bug fixed by 5697 exists here none the less. Add the same range check to `Decodable for VarInt`.
Like a cockroach that will just never fucking die ...
5c76a41 to
4a71193
Compare
|
Sweet, re-ordered the patches. No other changes. |
Manually backport #5697. On
mastertheVarInttype is gone but the deserialization bug fixed by 5697 exists here none the less.Add the same range check to
Decodable for VarInt.