mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-29 18:20:58 +02:00
Merge #18416: util: Limit decimal range of numbers ParseScript accepts
9ab14e4d21
Limit decimal range of numbers ParseScript accepts (pierrenn) Pull request description: Following up on this suggestion : https://github.com/bitcoin/bitcoin/pull/18413#issuecomment-602966490, prevent the output of `atoi64` in the `core_read.cpp:ParseScript` helper to send to `CScriptNum::serialize` values wider than 32-bit. Since the `ParseScript` helper is only used by the tool defined in `bitcoin-tx.cpp`, this only prevents users to provide too much unrealistic values. ACKs for top commit: laanwj: ACK9ab14e4d21
Tree-SHA512: ee228269d19d04e8fee0aa7c0ae2bb0a2b437b8e574356e8d9b2279318242057d51fcf39a842aa3afe27408d0f2d5276df245d07a3f4828644a366f80587b666
This commit is contained in:
@ -258,6 +258,40 @@
|
||||
"output_cmp": "txcreatescript4.json",
|
||||
"description": "Create a new transaction with a single output script (OP_DROP) in a P2SH, wrapped in a P2SH (output as json)"
|
||||
},
|
||||
{ "exec": "./bitcoin-tx",
|
||||
"args": ["-create", "outscript=0:9999999999"],
|
||||
"return_code": 1,
|
||||
"error_txt": "error: script parse error: decimal numeric value only allowed in the range -0xFFFFFFFF...0xFFFFFFFF",
|
||||
"description": "Try to parse an output script with a decimal number above the allowed range"
|
||||
},
|
||||
{ "exec": "./bitcoin-tx",
|
||||
"args": ["-create", "outscript=0:4294967296"],
|
||||
"return_code": 1,
|
||||
"error_txt": "error: script parse error: decimal numeric value only allowed in the range -0xFFFFFFFF...0xFFFFFFFF",
|
||||
"description": "Try to parse an output script with a decimal number just above the allowed range"
|
||||
},
|
||||
{ "exec": "./bitcoin-tx",
|
||||
"args": ["-create", "outscript=0:4294967295"],
|
||||
"output_cmp": "txcreatescript5.hex",
|
||||
"description": "Try to parse an output script with a decimal number at the upper limit of the allowed range"
|
||||
},
|
||||
{ "exec": "./bitcoin-tx",
|
||||
"args": ["-create", "outscript=0:-9999999999"],
|
||||
"return_code": 1,
|
||||
"error_txt": "error: script parse error: decimal numeric value only allowed in the range -0xFFFFFFFF...0xFFFFFFFF",
|
||||
"description": "Try to parse an output script with a decimal number below the allowed range"
|
||||
},
|
||||
{ "exec": "./bitcoin-tx",
|
||||
"args": ["-create", "outscript=0:-4294967296"],
|
||||
"return_code": 1,
|
||||
"error_txt": "error: script parse error: decimal numeric value only allowed in the range -0xFFFFFFFF...0xFFFFFFFF",
|
||||
"description": "Try to parse an output script with a decimal number just below the allowed range"
|
||||
},
|
||||
{ "exec": "./bitcoin-tx",
|
||||
"args": ["-create", "outscript=0:-4294967295"],
|
||||
"output_cmp": "txcreatescript6.hex",
|
||||
"description": "Try to parse an output script with a decimal number at the lower limit of the allowed range"
|
||||
},
|
||||
{ "exec": "./bitcoin-tx",
|
||||
"args":
|
||||
["-create", "nversion=1",
|
||||
|
1
test/util/data/txcreatescript5.hex
Normal file
1
test/util/data/txcreatescript5.hex
Normal file
@ -0,0 +1 @@
|
||||
02000000000100000000000000000605ffffffff0000000000
|
1
test/util/data/txcreatescript6.hex
Normal file
1
test/util/data/txcreatescript6.hex
Normal file
@ -0,0 +1 @@
|
||||
02000000000100000000000000000605ffffffff8000000000
|
Reference in New Issue
Block a user