diff options
| author | bitflash-maintainer <noreply@bitflash.invalid> | 2026-09-05 03:16:12 +0000 |
|---|---|---|
| committer | bitflash-maintainer <noreply@bitflash.invalid> | 2026-09-05 03:16:12 +0000 |
| commit | 36201d2795b7b49beb1a837b0252134096beb64d (patch) | |
| tree | 3283b5ab0b8c41a8707a93dd95d0b5b26afeb9c4 /src/bip32.cpp | |
| parent | 60538c5a935787521a5ad8c2a7dce52b5f250f3a (diff) | |
compactblock: fail closed on RAND_bytes error, bound reconstruction allocation
Two fixes to the file imported in the previous commit. Kept separate so the
deviation from upstream's bytes is reviewable on its own.
BuildCompactBlock ignored the RAND_bytes return value. On failure nonceBytes
is left uninitialised and an indeterminate shortIdNonce is memcpy'd out and
sent on the wire -- and that nonce is exactly what the file relies on being
unpredictable so short IDs cannot be precomputed before a block exists or
ground across blocks. Every other RAND_bytes call site in this tree
(bip32.cpp:203, db.cpp:2462, db.cpp:2469) checks for != 1 and fails closed;
this one now does too. The caller falls back to full-block relay.
TryReconstructBlock sized a vector directly from the wire. nTotal is the sum
of two deserialised vector lengths, and serialize.h bounds a vector only by
MAX_SIZE (0x02000000), so once the P2P handlers are wired a single small
message could ask this node to default-construct ~33M CTransactions. The
smallest a transaction can serialise to is 10 bytes, so no block within
MAX_BLOCK_SIZE holds more than MAX_BLOCK_SIZE/10 of them; anything above
that is not a block this node could accept under any circumstance.
Rejecting falls back to full-block relay, which is always correct.
Neither is reachable today -- nothing feeds these functions from the network
yet -- but both are latent the moment the message handlers land, which is
the wrong time to be finding them.
test_compactblock (17 checks) and all 14 selftests pass with both in place.
Diffstat (limited to 'src/bip32.cpp')
0 files changed, 0 insertions, 0 deletions