From 07d1a50aee407bcdc32c884801290ee2724637ea Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Sun, 22 Apr 2012 13:44:12 -0400 Subject: [PATCH] Test ScriptSigArgsExpected() for error, before accumulating return value --- src/main.cpp | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 2473662..1bb64a6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -304,6 +304,8 @@ bool CTransaction::AreInputsStandard(const MapPrevTx& mapInputs) const if (!Solver(prevScript, whichType, vSolutions)) return false; int nArgsExpected = ScriptSigArgsExpected(whichType, vSolutions); + if (nArgsExpected < 0) + return false; // Transactions with extra stuff in their scriptSigs are // non-standard. Note that this EvalScript() call will @@ -325,10 +327,15 @@ bool CTransaction::AreInputsStandard(const MapPrevTx& mapInputs) const return false; if (whichType2 == TX_SCRIPTHASH) return false; - nArgsExpected += ScriptSigArgsExpected(whichType2, vSolutions2); + + int tmpExpected; + tmpExpected = ScriptSigArgsExpected(whichType2, vSolutions2); + if (tmpExpected < 0) + return false; + nArgsExpected += tmpExpected; } - if (stack.size() != nArgsExpected) + if (stack.size() != (unsigned int)nArgsExpected) return false; } -- 1.7.1