diff options
author | djm@openbsd.org <djm@openbsd.org> | 2016-04-09 12:39:30 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2016-04-13 10:44:06 +1000 |
commit | dce19bf6e4a2a3d0b13a81224de63fc316461ab9 (patch) | |
tree | b97a0ac4f71bf5c6d5a6e35bd11396cf02dcd70a /authfile.c | |
parent | 5f41f030e2feb5295657285aa8c6602c7810bc4b (diff) | |
download | openssh-git-dce19bf6e4a2a3d0b13a81224de63fc316461ab9.tar.gz |
upstream commit
make private key loading functions consistently handle NULL
key pointer arguments; ok markus@
Upstream-ID: 92038726ef4a338169c35dacc9c5a07fcc7fa761
Diffstat (limited to 'authfile.c')
-rw-r--r-- | authfile.c | 34 |
1 files changed, 22 insertions, 12 deletions
@@ -1,4 +1,4 @@ -/* $OpenBSD: authfile.c,v 1.120 2015/12/11 04:21:11 mmcc Exp $ */ +/* $OpenBSD: authfile.c,v 1.121 2016/04/09 12:39:30 djm Exp $ */ /* * Copyright (c) 2000, 2013 Markus Friedl. All rights reserved. * @@ -147,7 +147,8 @@ sshkey_load_public_rsa1(int fd, struct sshkey **keyp, char **commentp) struct sshbuf *b = NULL; int r; - *keyp = NULL; + if (keyp != NULL) + *keyp = NULL; if (commentp != NULL) *commentp = NULL; @@ -200,7 +201,8 @@ sshkey_load_private_type(int type, const char *filename, const char *passphrase, { int fd, r; - *keyp = NULL; + if (keyp != NULL) + *keyp = NULL; if (commentp != NULL) *commentp = NULL; @@ -231,6 +233,8 @@ sshkey_load_private_type_fd(int fd, int type, const char *passphrase, struct sshbuf *buffer = NULL; int r; + if (keyp != NULL) + *keyp = NULL; if ((buffer = sshbuf_new()) == NULL) { r = SSH_ERR_ALLOC_FAIL; goto out; @@ -255,7 +259,8 @@ sshkey_load_private(const char *filename, const char *passphrase, struct sshbuf *buffer = NULL; int r, fd; - *keyp = NULL; + if (keyp != NULL) + *keyp = NULL; if (commentp != NULL) *commentp = NULL; @@ -408,7 +413,8 @@ sshkey_load_cert(const char *filename, struct sshkey **keyp) char *file = NULL; int r = SSH_ERR_INTERNAL_ERROR; - *keyp = NULL; + if (keyp != NULL) + *keyp = NULL; if (asprintf(&file, "%s-cert.pub", filename) == -1) return SSH_ERR_ALLOC_FAIL; @@ -418,11 +424,12 @@ sshkey_load_cert(const char *filename, struct sshkey **keyp) } if ((r = sshkey_try_load_public(pub, file, NULL)) != 0) goto out; - - *keyp = pub; - pub = NULL; + /* success */ + if (keyp != NULL) { + *keyp = pub; + pub = NULL; + } r = 0; - out: free(file); sshkey_free(pub); @@ -437,7 +444,8 @@ sshkey_load_private_cert(int type, const char *filename, const char *passphrase, struct sshkey *key = NULL, *cert = NULL; int r; - *keyp = NULL; + if (keyp != NULL) + *keyp = NULL; switch (type) { #ifdef WITH_OPENSSL @@ -467,8 +475,10 @@ sshkey_load_private_cert(int type, const char *filename, const char *passphrase, (r = sshkey_cert_copy(cert, key)) != 0) goto out; r = 0; - *keyp = key; - key = NULL; + if (keyp != NULL) { + *keyp = key; + key = NULL; + } out: sshkey_free(key); sshkey_free(cert); |