go.crypto/openpgp: fix hash presence checks.
At some point in the distant past, crypto.Hash.New() changed from returning nil when a hash function wasn't provided, to panicing. Some of the code in openpgp predates this and was still using the nil check. LGTM=bradfitz R=sburford, bradfitz CC=golang-codereviews https://golang.org/cl/104850045
This commit is contained in:
+2
-2
@@ -91,10 +91,10 @@ func Parse(r io.Reader) (f func(out, in []byte), err error) {
|
||||
if !ok {
|
||||
return nil, errors.UnsupportedError("hash for S2K function: " + strconv.Itoa(int(buf[1])))
|
||||
}
|
||||
h := hash.New()
|
||||
if h == nil {
|
||||
if !hash.Available() {
|
||||
return nil, errors.UnsupportedError("hash not available: " + strconv.Itoa(int(hash)))
|
||||
}
|
||||
h := hash.New()
|
||||
|
||||
switch buf[0] {
|
||||
case 0:
|
||||
|
||||
Reference in New Issue
Block a user