Skip to content

Commit bbbbaa0

Browse files
author
MarcoFalke
committed
Fix unsigned integer overflows in interpreter
1 parent fc642c3 commit bbbbaa0

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/script/interpreter.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ bool CastToBool(const valtype& vch)
5151
* Script is a stack machine (like Forth) that evaluates a predicate
5252
* returning a bool indicating valid or not. There are no loops.
5353
*/
54-
#define stacktop(i) (stack.at(stack.size()+(i)))
55-
#define altstacktop(i) (altstack.at(altstack.size()+(i)))
54+
#define stacktop(i) (stack.at(size_t(int64_t(stack.size()) + int64_t{i})))
55+
#define altstacktop(i) (altstack.at(size_t(int64_t(altstack.size()) + int64_t{i})))
5656
static inline void popstack(std::vector<valtype>& stack)
5757
{
5858
if (stack.empty())

test/sanitizer_suppressions/ubsan

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ unsigned-integer-overflow:MurmurHash3
5555
unsigned-integer-overflow:CBlockPolicyEstimator::processBlockTx
5656
unsigned-integer-overflow:TxConfirmStats::EstimateMedianVal
5757
unsigned-integer-overflow:prevector.h
58-
unsigned-integer-overflow:EvalScript
5958
unsigned-integer-overflow:InsecureRandomContext::rand64
6059
unsigned-integer-overflow:InsecureRandomContext::SplitMix64
6160
unsigned-integer-overflow:bitset_detail::PopCount

0 commit comments

Comments
 (0)