diff options
author | MacroFake <falke.marco@gmail.com> | 2022-10-26 10:12:21 +0200 |
---|---|---|
committer | MacroFake <falke.marco@gmail.com> | 2022-10-26 10:12:27 +0200 |
commit | cf288377c03577ba3059e56c6c8ad133f54c3342 (patch) | |
tree | 062cc763b8e7b2eaae4cb07c9d355fe47869e01f /src | |
parent | 28cf75697186ea8e473e120a643994bdf8237d6c (diff) | |
parent | 9153ff3e274953ea0d92d53ddab4c72deeace1b1 (diff) | |
download | bitcoin-cf288377c03577ba3059e56c6c8ad133f54c3342.tar.xz |
Merge bitcoin/bitcoin#26275: Fix crash on deriveaddresses when index is 2147483647 (2^31-1)
9153ff3e274953ea0d92d53ddab4c72deeace1b1 rpc: add non-regression test about deriveaddresses crash when index is 2147483647 (muxator)
addf9d6502db12cebcc5976df3111cac1a369b82 rpc: fix crash in deriveaddresses when derivation index is 2147483647 (muxator)
Pull request description:
This PR is a proposal for fixing #26274 (better described there).
The problem is due to a signed int wrapping when the `index` parameter of the `deriveaddresses` RPC call has the value `2^31-1`.
```C++
for (int i = range_begin; i <= range_end; ++i) {
```
* the first commit adds a "temporary" test case (`test/functional/rpc_deriveaddresses_crash.py`) that shows the crash, and can be used to generate a core dump;
* the second commit fixes the problem giving an explicit size to the `i` variable in a for loop, from `int` to `int64_t`. The same commit also removes the ephemeral test case and adds a passing test to `test/functional/rpc_deriveaddresses.py`, in order to prevent future regressions.
This is my first submission to this project and I do not know its conventions. Please advise if something needs to be changed.
ACKs for top commit:
achow101:
ACK 9153ff3e274953ea0d92d53ddab4c72deeace1b1
Tree-SHA512: 0477b57b15dc2c682cf539d6002f100d44a8c7e668041aa3340c39dcdbd40e083c75dec6896b6c076b044a01c2e5254272ae6696d8a1467539391926f270940a
Diffstat (limited to 'src')
-rw-r--r-- | src/rpc/output_script.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/rpc/output_script.cpp b/src/rpc/output_script.cpp index 744f809814..a980c609e8 100644 --- a/src/rpc/output_script.cpp +++ b/src/rpc/output_script.cpp @@ -273,7 +273,7 @@ static RPCHelpMan deriveaddresses() UniValue addresses(UniValue::VARR); - for (int i = range_begin; i <= range_end; ++i) { + for (int64_t i = range_begin; i <= range_end; ++i) { FlatSigningProvider provider; std::vector<CScript> scripts; if (!desc->Expand(i, key_provider, scripts, provider)) { |