Check input data for NewPrivateKey (#399)

This commit is contained in:
Pavel Odintsov 2016-10-03 17:36:51 +03:00 committed by Miek Gieben
parent 574f29b9d6
commit 8d8a1ec575
1 changed files with 1 additions and 1 deletions

View File

@ -14,7 +14,7 @@ import (
// NewPrivateKey returns a PrivateKey by parsing the string s.
// s should be in the same form of the BIND private key files.
func (k *DNSKEY) NewPrivateKey(s string) (crypto.PrivateKey, error) {
if s[len(s)-1] != '\n' { // We need a closing newline
if s == "" || s[len(s)-1] != '\n' { // We need a closing newline
return k.ReadPrivateKey(strings.NewReader(s+"\n"), "")
}
return k.ReadPrivateKey(strings.NewReader(s), "")