Skip to content

Commit fd25d34

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#24319: refactor: Avoid unsigned integer overflow in core_write
fa60656 refactor: Avoid unsigned integer overflow in core_write (MarcoFalke) Pull request description: Also, I find the new code a bit easier to understand. ACKs for top commit: shaavan: Code Review ACK fa60656 Tree-SHA512: cd751e3b4dc97ef525eb8be8d0a49e9629389cb114df18d59a06e05388822af2939078e937f01494e6b317d601743b1a433ba47aa40c4dc602372d1f0fd0dc11
2 parents 3eec29e + fa60656 commit fd25d34

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

src/core_write.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ std::string FormatScript(const CScript& script)
6565
ret += strprintf("0x%x ", HexStr(std::vector<uint8_t>(it2, script.end())));
6666
break;
6767
}
68-
return ret.substr(0, ret.size() - 1);
68+
return ret.substr(0, ret.empty() ? ret.npos : ret.size() - 1);
6969
}
7070

7171
const std::map<unsigned char, std::string> mapSigHashTypes = {

test/sanitizer_suppressions/ubsan

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ unsigned-integer-overflow:arith_uint256.h
4747
unsigned-integer-overflow:common/bloom.cpp
4848
unsigned-integer-overflow:coins.cpp
4949
unsigned-integer-overflow:compressor.cpp
50-
unsigned-integer-overflow:core_write.cpp
5150
unsigned-integer-overflow:crypto/
5251
unsigned-integer-overflow:hash.cpp
5352
unsigned-integer-overflow:policy/fees.cpp

0 commit comments

Comments
 (0)