summaryrefslogtreecommitdiff
path: root/sshbuf.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2016-01-12 23:42:54 +0000
committerDamien Miller <djm@mindrot.org>2016-01-13 10:48:11 +1100
commit9a728cc918fad67c8a9a71201088b1e150340ba4 (patch)
treedca3a776b4cc5a45abbca64eb797d4ec51b7779b /sshbuf.c
parent4626cbaf78767fc8e9c86dd04785386c59ae0839 (diff)
upstream commit
use explicit_bzero() more liberally in the buffer code; ok deraadt Upstream-ID: 0ece37069fd66bc6e4f55eb1321f93df372b65bf
Diffstat (limited to 'sshbuf.c')
-rw-r--r--sshbuf.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sshbuf.c b/sshbuf.c
index f52b56767..4d6e0ea0a 100644
--- a/sshbuf.c
+++ b/sshbuf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshbuf.c,v 1.5 2015/12/11 04:21:12 mmcc Exp $ */ 1/* $OpenBSD: sshbuf.c,v 1.6 2016/01/12 23:42:54 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2011 Damien Miller 3 * Copyright (c) 2011 Damien Miller
4 * 4 *
@@ -134,7 +134,7 @@ sshbuf_fromb(struct sshbuf *buf)
134void 134void
135sshbuf_init(struct sshbuf *ret) 135sshbuf_init(struct sshbuf *ret)
136{ 136{
137 bzero(ret, sizeof(*ret)); 137 explicit_bzero(ret, sizeof(*ret));
138 ret->alloc = SSHBUF_SIZE_INIT; 138 ret->alloc = SSHBUF_SIZE_INIT;
139 ret->max_size = SSHBUF_SIZE_MAX; 139 ret->max_size = SSHBUF_SIZE_MAX;
140 ret->readonly = 0; 140 ret->readonly = 0;
@@ -178,7 +178,7 @@ sshbuf_free(struct sshbuf *buf)
178 explicit_bzero(buf->d, buf->alloc); 178 explicit_bzero(buf->d, buf->alloc);
179 free(buf->d); 179 free(buf->d);
180 } 180 }
181 bzero(buf, sizeof(*buf)); 181 explicit_bzero(buf, sizeof(*buf));
182 if (!dont_free) 182 if (!dont_free)
183 free(buf); 183 free(buf);
184} 184}
@@ -194,7 +194,7 @@ sshbuf_reset(struct sshbuf *buf)
194 return; 194 return;
195 } 195 }
196 if (sshbuf_check_sanity(buf) == 0) 196 if (sshbuf_check_sanity(buf) == 0)
197 bzero(buf->d, buf->alloc); 197 explicit_bzero(buf->d, buf->alloc);
198 buf->off = buf->size = 0; 198 buf->off = buf->size = 0;
199 if (buf->alloc != SSHBUF_SIZE_INIT) { 199 if (buf->alloc != SSHBUF_SIZE_INIT) {
200 if ((d = realloc(buf->d, SSHBUF_SIZE_INIT)) != NULL) { 200 if ((d = realloc(buf->d, SSHBUF_SIZE_INIT)) != NULL) {
@@ -253,7 +253,7 @@ sshbuf_set_max_size(struct sshbuf *buf, size_t max_size)
253 rlen = roundup(buf->size, SSHBUF_SIZE_INC); 253 rlen = roundup(buf->size, SSHBUF_SIZE_INC);
254 if (rlen > max_size) 254 if (rlen > max_size)
255 rlen = max_size; 255 rlen = max_size;
256 bzero(buf->d + buf->size, buf->alloc - buf->size); 256 explicit_bzero(buf->d + buf->size, buf->alloc - buf->size);
257 SSHBUF_DBG(("new alloc = %zu", rlen)); 257 SSHBUF_DBG(("new alloc = %zu", rlen));
258 if ((dp = realloc(buf->d, rlen)) == NULL) 258 if ((dp = realloc(buf->d, rlen)) == NULL)
259 return SSH_ERR_ALLOC_FAIL; 259 return SSH_ERR_ALLOC_FAIL;