summaryrefslogtreecommitdiff
path: root/ssh-keygen.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2020-05-18 04:29:35 +0000
committerDamien Miller <djm@mindrot.org>2020-05-27 10:13:17 +1000
commit2a63ce5cd6d0e782783bf721462239b03757dd49 (patch)
treedc7ccb95604ba6f0fc023a2b6c54e707409eb71d /ssh-keygen.c
parent4b307faf2fb0e63e51a550b37652f7f972df9676 (diff)
upstream: avoid possible NULL deref; from Pedro Martelletto
OpenBSD-Commit-ID: e6099c3fbb70aa67eb106e84d8b43f1fa919b721
Diffstat (limited to 'ssh-keygen.c')
-rw-r--r--ssh-keygen.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/ssh-keygen.c b/ssh-keygen.c
index bcf1ece39..405903319 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-keygen.c,v 1.410 2020/05/13 09:55:57 djm Exp $ */ 1/* $OpenBSD: ssh-keygen.c,v 1.411 2020/05/18 04:29:35 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -2954,14 +2954,16 @@ do_download_sk(const char *skprovider, const char *device)
2954 &keys, &nkeys)) != 0) { 2954 &keys, &nkeys)) != 0) {
2955 if (i == 0 && r == SSH_ERR_KEY_WRONG_PASSPHRASE) 2955 if (i == 0 && r == SSH_ERR_KEY_WRONG_PASSPHRASE)
2956 continue; 2956 continue;
2957 freezero(pin, strlen(pin)); 2957 if (pin != NULL)
2958 freezero(pin, strlen(pin));
2958 error("Unable to load resident keys: %s", ssh_err(r)); 2959 error("Unable to load resident keys: %s", ssh_err(r));
2959 return -1; 2960 return -1;
2960 } 2961 }
2961 } 2962 }
2962 if (nkeys == 0) 2963 if (nkeys == 0)
2963 logit("No keys to download"); 2964 logit("No keys to download");
2964 freezero(pin, strlen(pin)); 2965 if (pin != NULL)
2966 freezero(pin, strlen(pin));
2965 2967
2966 for (i = 0; i < nkeys; i++) { 2968 for (i = 0; i < nkeys; i++) {
2967 if (keys[i]->type != KEY_ECDSA_SK && 2969 if (keys[i]->type != KEY_ECDSA_SK &&