Skip to content

Commit

Permalink
Make IsCanonicalScript() check the hash type more thoroughly
Browse files Browse the repository at this point in the history
0 and 128 were previously accepted as standard hash type.

Note that this function is not active in the current verification
code.
  • Loading branch information
sipa committed Dec 22, 2012
1 parent 23826f1 commit bffc744
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/script.cpp
Expand Up @@ -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");
Expand Down

0 comments on commit bffc744

Please sign in to comment.