Skip to content

Commit 2b2c970

Browse files
committed
Merge bitcoin/bitcoin#26149: Fix assert failure in miniscript string parsing
648f695 Correct sanity-checking script_size calculation (Pieter Wuille) Pull request description: Fix a bug in the script_size sanity-check in the miniscript string parser, found by oss-fuzz in https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=51636, and introduced in e8cc2e4 (#25540). This bug would cause an assertion failure when feeding a miniscript with a `thresh(k,...)` fragment, with k >= 128, to an RPC. ACKs for top commit: darosior: utACK 648f695 achow101: ACK 648f695 Tree-SHA512: d86a0721758cd1e42ef02050b542f0935efdc19447a1ca76a3ade96352a6ee8261eef3d4a5cbdec77bf0ad14dfed42e9eb6bd4246b816a9f6f06d786900da9e7
2 parents 74e54cc + 648f695 commit 2b2c970

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/script/miniscript.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ inline NodeRef<Key> Parse(Span<const char> in, const Ctx& ctx)
12211221
// n = 1 here because we read the first WRAPPED_EXPR before reaching THRESH
12221222
to_parse.emplace_back(ParseContext::THRESH, 1, k);
12231223
to_parse.emplace_back(ParseContext::WRAPPED_EXPR, -1, -1);
1224-
script_size += 2 + (k > 16);
1224+
script_size += 2 + (k > 16) + (k > 0x7f) + (k > 0x7fff) + (k > 0x7fffff);
12251225
} else if (Const("andor(", in)) {
12261226
to_parse.emplace_back(ParseContext::ANDOR, -1, -1);
12271227
to_parse.emplace_back(ParseContext::CLOSE_BRACKET, -1, -1);

0 commit comments

Comments
 (0)