AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 21 Bitcoin

Merge bitcoin/bitcoin#36777: refactor: rpc: doc: Mark longpoll counter u32

Public commit record

What the developer wrote

Authored by merge-script

91/100 · Strong
Merge bitcoin/bitcoin#36777: refactor: rpc: doc: Mark longpoll counter u32

fa8817e6087e0d112f6421de47cb2bc7504b3ca1 refactor: rpc: doc: Mark longpoll counter u32 (MarcoFalke)

Pull request description:

The counter will only ever be a valid u32 value in normal operation, so document that without changing any behavior.

In theory, the behavior could be changed to use `LocaleIndependentAtoi<uint32_t>()`, but this is left for the future.

The change is needed to be able to fuzz the `rpc` target.

To test after compiling with `-DSANITIZERS=undefined,integer,float-divide-by-zero`:

```
$ base64 /tmp/a.crash
Z2V0YmxvY2t0ZW1wbGF0ZVyzXC1sb25ncG9sbGlkXNHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR
AAAAAAAAAAAAAAAgAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAABCQkJCQkJCQkJCQkJCQkJCQkJC
QkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJC
QkJCQkJCQkJCQkJCQkLR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR
0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHRZ2VsA6NjA2+pYysAmfcAuMXhQwjp7WJsXA==

$ FUZZ=rpc ./bld-cmake/test/with_sanitizer_env.py ./bld-cmake/bin/fuzz /tmp/a.crash
src/rpc/mining.cpp:842:42: runtime error: implicit conversion from type 'long' of value 9223372036854775807 (64-bit, signed) to type 'unsigned int' changed the value to 4294967295 (32-bit, unsigned)
#0 0x5603ba69a874 in getblocktemplate()::$_0::operator()(RPCMethod const&, JSONRPCRequest const&) const
...
```

Or:

```
$ UBSAN_OPTIONS="suppressions=$(pwd)/test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=0:report_error_type=1" ./bld-cmake/bin/bitcoind -datadir=/tmp -regtest &

$ ./bld-cmake/bin/bitcoin-cli -datadir=/tmp -regtest getblocktemplate '{"rules":["segwit"],"longpollid":"00000000000000000000000000000000000000000000000000000000000000009223372036854775807"}'

ACKs for top commit:
sedited:
ACK fa8817e6087e0d112f6421de47cb2bc7504b3ca1
darosior:
utACK fa8817e6087e0d112f6421de47cb2bc7504b3ca1

Tree-SHA512: 607c14632d900c3a99b82560c858967bfd1475f6d274c97942428ebe2f26fb47d5086de4fb142814107a7231d2443d732addb4b27b23b01ab21202b4bf47848b
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This is a small code cleanup in Bitcoin Core's getblocktemplate RPC. It changes the type of an internal counter from 'unsigned int' to the explicitly-sized 'uint32_t' and documents that the long-poll counter is expected to be a 32-bit value. The patch does not change runtime behavior; it merely makes the existing implicit truncation explicit so that fuzzing and sanitizer tools don't flag it as suspicious. There is no direct security fix here, but making the code's assumptions explicit helps future testing catch real bugs.

Recommended action

No urgent action required. This is a refactor/documentation change. Operators and reviewers should note that the longpollid counter is now explicitly 32-bit; if a future change moves to LocaleIndependentAtoi<uint32_t>(), ensure it also handles malformed or out-of-range input gracefully.

Security signals we found

01

UBSan runtime error: implicit conversion from signed 64-bit long to unsigned int changes value

02

User-controlled input parsed via LocaleIndependentAtoi<int64_t> and assigned to unsigned int

03

Explicit cast added to make truncation visible, but no bounds check introduced

04

Change motivated by fuzz target (FUZZ=rpc) compatibility, not by a reported exploit

Risk score

Why this scored 21/100

Our methodology →
Potential impact 3/30
Exploitability 2/25
Stealth signal 2/15
Affected reach 2/15
Confidence 8/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.