Skip to content

Commit 11c6a86

Browse files
committed
Merge bitcoin/bitcoin#33007: test: fix ReadTopologicalSet unsigned integer overflow
31c4e77 test: fix ReadTopologicalSet unsigned integer overflow (ismaelsadeeq) Pull request description: This PR is a simple fix for a potential unsigned integer overflow in ReadTopologicalSet. We obtain the value of `mask` from fuzz input, which can be the maximum representable value. Adding 1 to it would then cause an overflow. The fix skips the addition when the read value is already the maximum. See bitcoin/bitcoin#30605 (comment) for more context ACKs for top commit: maflcko: lgtm ACK 31c4e77 Tree-SHA512: f58d7907f66a0de0ed8d4b1cad6a4971f65925a99f3c030537c21c4d84126b643257c65865242caf7d445b9cbb7a71a1816a9f870ab7520625c4c16cd41979cb
2 parents 9bc3343 + 31c4e77 commit 11c6a86

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/test/fuzz/cluster_linearize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ SetType ReadTopologicalSet(const DepGraph<SetType>& depgraph, const SetType& tod
304304
try {
305305
reader >> VARINT(mask);
306306
} catch(const std::ios_base::failure&) {}
307-
mask += non_empty;
307+
if (mask != uint64_t(-1)) mask += non_empty;
308308

309309
SetType ret;
310310
for (auto i : todo) {

0 commit comments

Comments
 (0)