From 3aaafbd7faafcb5a5b5e5ec4f208224df3abbb6e Mon Sep 17 00:00:00 2001 From: "Owain G. Ainsworth" Date: Thu, 7 Nov 2013 17:09:22 +0000 Subject: [PATCH] handle op_checksig with an empty signature on the stack. Crash found by jy-p, fix by me. --- opcode.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/opcode.go b/opcode.go index 21a4ee187..2ef4444ec 100644 --- a/opcode.go +++ b/opcode.go @@ -1662,6 +1662,13 @@ func opcodeCheckSig(op *parsedOpcode, s *Script) error { return err } + // Signature actually needs needs to be longer than this, but we need + // at least 1 byte for the below. btcec will check full length upon + // parsing the signature. + if len(sigStr) < 1 { + return errors.New("Short signature") + } + // Trim off hashtype from the signature string. hashType := sigStr[len(sigStr)-1] sigStr = sigStr[:len(sigStr)-1]