Merge rust-bitcoin/rust-bitcoin#7058: consensus_encoding: fix wrong default limit in CompactSizeDecoder docs
What changed, and why it matters
This change only corrects a mistake in a code comment. The documentation for CompactSizeDecoder wrongly said the default size limit was 4,000,000, when the actual default is about 33.5 million (32 MB). No program behavior was changed; only the explanatory text was fixed.
No action needed; this is a non-functional documentation correction.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit is a documentation-only fix in consensus_encoding/src/compact_size.rs. It updates the CompactSizeDecoder doc comment to state the correct default limit (MAX_COMPACT_SIZE = 0x0200_0000 = 33,554,432 bytes) instead of the vec-decoder limit (MAX_VEC_SIZE = 4,000,000). The implementation and constants were already correct; only the doc string was inaccurate.
Changed components
consensus_encoding/src/compact_size.rs documentationInspect captured patch +4 / −4
### consensus_encoding/src/compact_size.rs
@@ -129,10 +129,10 @@ impl ExactSizeEncoder for CompactSizeEncoder {
/// Decodes a compact size encoded integer as a length prefix.
///
/// The decoded value is returned as a `usize` and is bounded by a configurable limit (default:
-/// 4,000,000). This limit is a denial-of-service protection: a malicious peer can send a compact
-/// size value up to 2^64-1, and without a limit check the caller might attempt to allocate an
-/// enormous buffer based on that value. [`CompactSizeDecoder`] prevents this by rejecting values
-/// that exceed the limit before returning them to the caller.
+/// 32 MB, or 33,554,432 bytes). This limit is a denial-of-service protection: a malicious peer can
+/// send a compact size value up to 2^64-1, and without a limit check the caller might attempt to
+/// allocate an enormous buffer based on that value. [`CompactSizeDecoder`] prevents this by
+/// rejecting values that exceed the limit before returning them to the caller.
///
/// If you are decoding an arbitrary `u64` integer that is genuinely not a length prefix, use
/// [`CompactSizeU64Decoder`] instead.Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.