Skip to content

Commit

Permalink
refactor: Avoid unsigned integer overflow in core_write
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoFalke committed Feb 11, 2022
1 parent b79c40b commit fa60656
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 1 addition & 1 deletion src/core_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ std::string FormatScript(const CScript& script)
ret += strprintf("0x%x ", HexStr(std::vector<uint8_t>(it2, script.end())));
break;
}
return ret.substr(0, ret.size() - 1);
return ret.substr(0, ret.empty() ? ret.npos : ret.size() - 1);
}

const std::map<unsigned char, std::string> mapSigHashTypes = {
Expand Down
1 change: 0 additions & 1 deletion test/sanitizer_suppressions/ubsan
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ unsigned-integer-overflow:arith_uint256.h
unsigned-integer-overflow:common/bloom.cpp
unsigned-integer-overflow:coins.cpp
unsigned-integer-overflow:compressor.cpp
unsigned-integer-overflow:core_write.cpp
unsigned-integer-overflow:crypto/
unsigned-integer-overflow:hash.cpp
unsigned-integer-overflow:policy/fees.cpp
Expand Down

0 comments on commit fa60656

Please sign in to comment.