check for 0 length strings in pubkey parser.
We check length later, but we assumed it was always 1 bytes long. Not always the case. I'm a little depressed that this bug was there.
This commit is contained in:
parent
ff3fac426d
commit
de670bd5b2
1 changed files with 5 additions and 0 deletions
|
@ -6,6 +6,7 @@ package btcec
|
|||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
)
|
||||
|
@ -53,6 +54,10 @@ func ParsePubKey(pubKeyStr []byte, curve *KoblitzCurve) (key *ecdsa.PublicKey, e
|
|||
pubkey := ecdsa.PublicKey{}
|
||||
pubkey.Curve = curve
|
||||
|
||||
if len(pubKeyStr) == 0 {
|
||||
return nil, errors.New("pubkey string is empty")
|
||||
}
|
||||
|
||||
format := pubKeyStr[0]
|
||||
ybit := (format & 0x1) == 0x1
|
||||
format &= ^byte(0x1)
|
||||
|
|
Loading…
Reference in a new issue