diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2016-04-09 12:39:31 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2016-04-09 12:39:31 +0000 |
commit | cefd619bc56219895e0a3f16afb2360b48b95a61 (patch) | |
tree | 0598a8d9f3b0d6a0c5d5af6579315269ad238d80 /usr.bin/ssh/authfile.c | |
parent | c2dcfbd5d5019d5da7847ea22287988ee1e7c7d8 (diff) |
make private key loading functions consistently handle NULL
key pointer arguments; ok markus@
Diffstat (limited to 'usr.bin/ssh/authfile.c')
-rw-r--r-- | usr.bin/ssh/authfile.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/usr.bin/ssh/authfile.c b/usr.bin/ssh/authfile.c index ac2e226dcbd..59771cb09f7 100644 --- a/usr.bin/ssh/authfile.c +++ b/usr.bin/ssh/authfile.c @@ -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. * @@ -145,7 +145,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; @@ -195,7 +196,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; @@ -226,6 +228,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; @@ -250,7 +254,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; @@ -403,7 +408,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; @@ -413,11 +419,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); @@ -432,7 +439,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 @@ -462,8 +470,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); |