mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
Limit decimal range of numbers ParseScript accepts
This commit is contained in:
@@ -59,6 +59,14 @@ CScript ParseScript(const std::string& s)
|
||||
{
|
||||
// Number
|
||||
int64_t n = atoi64(*w);
|
||||
|
||||
//limit the range of numbers ParseScript accepts in decimal
|
||||
//since numbers outside -0xFFFFFFFF...0xFFFFFFFF are illegal in scripts
|
||||
if (n > int64_t{0xffffffff} || n < -1 * int64_t{0xffffffff}) {
|
||||
throw std::runtime_error("script parse error: decimal numeric value only allowed in the "
|
||||
"range -0xFFFFFFFF...0xFFFFFFFF");
|
||||
}
|
||||
|
||||
result << n;
|
||||
}
|
||||
else if (w->substr(0,2) == "0x" && w->size() > 2 && IsHex(std::string(w->begin()+2, w->end())))
|
||||
|
||||
Reference in New Issue
Block a user