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.
This commit is contained in:
Pieter Wuille 2012-12-19 01:24:00 +01:00
parent 23826f1b7f
commit bffc744444
1 changed files with 2 additions and 1 deletions

View File

@ -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");