From 930694cd059c4cad1868049b0413e5775425debf Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Sun, 15 Apr 2012 21:00:17 +0200 Subject: [PATCH] Fix crash --- kscan.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/kscan.go b/kscan.go index ff467c76..eb93af3a 100644 --- a/kscan.go +++ b/kscan.go @@ -41,9 +41,10 @@ func (k *RR_DNSKEY) ReadPrivateKey(q io.Reader, file string) (PrivateKey, error) case "7 (RSASHA1NSEC3SHA1)": p, e := readPrivateKeyRSA(m) if e != nil { - if !k.setPublicKeyInPrivate(p) { - return nil, ErrPrivKey - } + return nil, e + } + if !k.setPublicKeyInPrivate(p) { + return nil, ErrPrivKey } return p, e case "13 (ECDSAP256SHA256)": @@ -51,9 +52,10 @@ func (k *RR_DNSKEY) ReadPrivateKey(q io.Reader, file string) (PrivateKey, error) case "14 (ECDSAP384SHA384)": p, e := readPrivateKeyECDSA(m) if e != nil { - if !k.setPublicKeyInPrivate(p) { - return nil, ErrPrivKey - } + return nil, e + } + if !k.setPublicKeyInPrivate(p) { + return nil, ErrPrivKey } return p, e }