summaryrefslogtreecommitdiff
path: root/ssh-ed25519.c
diff options
context:
space:
mode:
authorjsg@openbsd.org <jsg@openbsd.org>2020-02-26 13:40:09 +0000
committerDamien Miller <djm@mindrot.org>2020-02-28 12:26:28 +1100
commitd5ba1c03278eb079438bb038266d80d7477d49cb (patch)
tree6d8dd2d802af796bcb7c9d6d018196a448bb9ff6 /ssh-ed25519.c
parent9e3220b585c5be19a7431ea4ff8884c137b3a81c (diff)
upstream: change explicit_bzero();free() to freezero()
While freezero() returns early if the pointer is NULL the tests for NULL in callers are left to avoid warnings about passing an uninitialised size argument across a function boundry. ok deraadt@ djm@ OpenBSD-Commit-ID: 2660fa334fcc7cd05ec74dd99cb036f9ade6384a
Diffstat (limited to 'ssh-ed25519.c')
-rw-r--r--ssh-ed25519.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/ssh-ed25519.c b/ssh-ed25519.c
index 5163e0297..7dee82707 100644
--- a/ssh-ed25519.c
+++ b/ssh-ed25519.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-ed25519.c,v 1.7 2016/04/21 06:08:02 djm Exp $ */ 1/* $OpenBSD: ssh-ed25519.c,v 1.8 2020/02/26 13:40:09 jsg Exp $ */
2/* 2/*
3 * Copyright (c) 2013 Markus Friedl <markus@openbsd.org> 3 * Copyright (c) 2013 Markus Friedl <markus@openbsd.org>
4 * 4 *
@@ -83,10 +83,8 @@ ssh_ed25519_sign(const struct sshkey *key, u_char **sigp, size_t *lenp,
83 r = 0; 83 r = 0;
84 out: 84 out:
85 sshbuf_free(b); 85 sshbuf_free(b);
86 if (sig != NULL) { 86 if (sig != NULL)
87 explicit_bzero(sig, slen); 87 freezero(sig, slen);
88 free(sig);
89 }
90 88
91 return r; 89 return r;
92} 90}
@@ -153,14 +151,10 @@ ssh_ed25519_verify(const struct sshkey *key,
153 /* success */ 151 /* success */
154 r = 0; 152 r = 0;
155 out: 153 out:
156 if (sm != NULL) { 154 if (sm != NULL)
157 explicit_bzero(sm, smlen); 155 freezero(sm, smlen);
158 free(sm); 156 if (m != NULL)
159 } 157 freezero(m, smlen); /* NB mlen may be invalid if r != 0 */
160 if (m != NULL) {
161 explicit_bzero(m, smlen); /* NB mlen may be invalid if r != 0 */
162 free(m);
163 }
164 sshbuf_free(b); 158 sshbuf_free(b);
165 free(ktype); 159 free(ktype);
166 return r; 160 return r;