diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -1313,6 +1313,21 @@ // Disabled opcodes. return set_error(serror, SCRIPT_ERR_DISABLED_OPCODE); } + // (in -- out) + if (stack.size() < 1) { + return set_error( + serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + } + valtype bin = stacktop(-1); + // big endian to little endian conversion + std::reverse(bin.begin(), bin.end()); + CScriptNum num(bin, false); + if (num > (INT_MAX >> 1) || num < (INT_MIN >> 1)) { + return set_error( + serror, SCRIPT_ERR_INVALID_BIN2NUM_OPERATION); + } + stack.pop_back(); + stack.push_back(num.getvch()); } break; case OP_NUM2BIN: {