aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/transport/ssh/auth_method.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-02-25 21:08:07 +0100
committerGitHub <noreply@github.com>2018-02-25 21:08:07 +0100
commitdefd0b861ca79845c8f06f7c826c769012404bbd (patch)
tree81437c18373b19bc4f85f88cdfb143815bc1570a /plumbing/transport/ssh/auth_method.go
parent721449aadc2792494d030ac37ee779025a9b2869 (diff)
parent779c88d4a407d3628f903e7c53ad5b4237ac618a (diff)
downloadgo-git-defd0b861ca79845c8f06f7c826c769012404bbd.tar.gz
Merge pull request #759 from mdelillo/invalid-ssh-key
plumbing: ssh, return error when creating public keys from invalid PEM
Diffstat (limited to 'plumbing/transport/ssh/auth_method.go')
-rw-r--r--plumbing/transport/ssh/auth_method.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/plumbing/transport/ssh/auth_method.go b/plumbing/transport/ssh/auth_method.go
index 0cdf2b7..84cfab2 100644
--- a/plumbing/transport/ssh/auth_method.go
+++ b/plumbing/transport/ssh/auth_method.go
@@ -124,6 +124,9 @@ type PublicKeys struct {
// (PKCS#1), DSA (OpenSSL), and ECDSA private keys.
func NewPublicKeys(user string, pemBytes []byte, password string) (*PublicKeys, error) {
block, _ := pem.Decode(pemBytes)
+ if block == nil {
+ return nil, errors.New("invalid PEM data")
+ }
if x509.IsEncryptedPEMBlock(block) {
key, err := x509.DecryptPEMBlock(block, []byte(password))
if err != nil {