diff options
author | Gregory Sanders <gsanders87@gmail.com> | 2017-12-14 14:04:47 -0500 |
---|---|---|
committer | Gregory Sanders <gsanders87@gmail.com> | 2017-12-14 14:04:47 -0500 |
commit | 176db6147421c3888076ab8be762a23d9b1bc0c5 (patch) | |
tree | 5625f624ab7b098cb1225f22337e6433a3b16108 /src | |
parent | c66adb286a89738a6a5218be2ecfea8e398878dd (diff) |
simplify CheckMinimalPush checks, add safety assert
Diffstat (limited to 'src')
-rw-r--r-- | src/script/interpreter.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index 3c3f92fe46..9401442f4d 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -220,15 +220,17 @@ bool static CheckPubKeyEncoding(const valtype &vchPubKey, unsigned int flags, co } bool static CheckMinimalPush(const valtype& data, opcodetype opcode) { + // Excludes OP_1NEGATE, OP_1-16 since they are by definition minimal + assert(0 <= opcode && opcode <= OP_PUSHDATA4); if (data.size() == 0) { // Could have used OP_0. return opcode == OP_0; } else if (data.size() == 1 && data[0] >= 1 && data[0] <= 16) { // Could have used OP_1 .. OP_16. - return opcode == OP_1 + (data[0] - 1); + return false; } else if (data.size() == 1 && data[0] == 0x81) { // Could have used OP_1NEGATE. - return opcode == OP_1NEGATE; + return false; } else if (data.size() <= 75) { // Could have used a direct push (opcode indicating number of bytes pushed + those bytes). return opcode == data.size(); |