aboutsummaryrefslogtreecommitdiff
path: root/src/core_read.cpp
diff options
context:
space:
mode:
authorpierrenn <git@pnn.sh>2020-03-24 16:17:58 +0900
committerpierrenn <git@pnn.sh>2020-03-27 15:51:05 +0900
commit9ab14e4d21c73d16d8d782f1576fe29e659e2a70 (patch)
treec5c0e040cc880f3faf0806b3748463bc7a133a5d /src/core_read.cpp
parent97b0687501cee77a9170f9e288755a5d268e9bd4 (diff)
downloadbitcoin-9ab14e4d21c73d16d8d782f1576fe29e659e2a70.tar.xz
Limit decimal range of numbers ParseScript accepts
Diffstat (limited to 'src/core_read.cpp')
-rw-r--r--src/core_read.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/core_read.cpp b/src/core_read.cpp
index 9a65b02585..d036955641 100644
--- a/src/core_read.cpp
+++ b/src/core_read.cpp
@@ -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())))