From bffc744444c19e25c60c8df999beb83192f96a8a Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Wed, 19 Dec 2012 01:24:00 +0100 Subject: [PATCH] Make IsCanonicalScript() check the hash type more thoroughly 0 and 128 were previously accepted as standard hash type. Note that this function is not active in the current verification code. --- src/script.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/script.cpp b/src/script.cpp index f65508aa..f63668ac 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -278,7 +278,8 @@ bool IsCanonicalSignature(const valtype &vchSig) { return error("Non-canonical signature: too short"); if (vchSig.size() > 73) return error("Non-canonical signature: too long"); - if (vchSig[vchSig.size() - 1] & 0x7C) + unsigned char nHashType = vchSig[vchSig.size() - 1] & (~(SIGHASH_ANYONECANPAY)); + if (nHashType < SIGHASH_ALL || nHashType > SIGHASH_SINGLE) return error("Non-canonical signature: unknown hashtype byte"); if (vchSig[0] != 0x30) return error("Non-canonical signature: wrong type");