diff options
author | djm@openbsd.org <djm@openbsd.org> | 2016-01-12 23:42:54 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2016-01-14 10:19:54 +1100 |
commit | 04bd8d019ccd906cac1a2b362517b8505f3759e6 (patch) | |
tree | 21704429e8bcf1a3c342ef485e249720c531a479 /sshbuf.c | |
parent | e91346dc2bbf460246df2ab591b7613908c1b0ad (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.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -134,7 +134,7 @@ sshbuf_fromb(struct sshbuf *buf) | |||
134 | void | 134 | void |
135 | sshbuf_init(struct sshbuf *ret) | 135 | sshbuf_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; |
@@ -180,7 +180,7 @@ sshbuf_free(struct sshbuf *buf) | |||
180 | bzero(buf->d, buf->alloc); | 180 | bzero(buf->d, buf->alloc); |
181 | free(buf->d); | 181 | free(buf->d); |
182 | } | 182 | } |
183 | bzero(buf, sizeof(*buf)); | 183 | explicit_bzero(buf, sizeof(*buf)); |
184 | if (!dont_free) | 184 | if (!dont_free) |
185 | free(buf); | 185 | free(buf); |
186 | } | 186 | } |
@@ -196,7 +196,7 @@ sshbuf_reset(struct sshbuf *buf) | |||
196 | return; | 196 | return; |
197 | } | 197 | } |
198 | if (sshbuf_check_sanity(buf) == 0) | 198 | if (sshbuf_check_sanity(buf) == 0) |
199 | bzero(buf->d, buf->alloc); | 199 | explicit_bzero(buf->d, buf->alloc); |
200 | buf->off = buf->size = 0; | 200 | buf->off = buf->size = 0; |
201 | if (buf->alloc != SSHBUF_SIZE_INIT) { | 201 | if (buf->alloc != SSHBUF_SIZE_INIT) { |
202 | if ((d = realloc(buf->d, SSHBUF_SIZE_INIT)) != NULL) { | 202 | if ((d = realloc(buf->d, SSHBUF_SIZE_INIT)) != NULL) { |
@@ -255,7 +255,7 @@ sshbuf_set_max_size(struct sshbuf *buf, size_t max_size) | |||
255 | rlen = roundup(buf->size, SSHBUF_SIZE_INC); | 255 | rlen = roundup(buf->size, SSHBUF_SIZE_INC); |
256 | if (rlen > max_size) | 256 | if (rlen > max_size) |
257 | rlen = max_size; | 257 | rlen = max_size; |
258 | bzero(buf->d + buf->size, buf->alloc - buf->size); | 258 | explicit_bzero(buf->d + buf->size, buf->alloc - buf->size); |
259 | SSHBUF_DBG(("new alloc = %zu", rlen)); | 259 | SSHBUF_DBG(("new alloc = %zu", rlen)); |
260 | if ((dp = realloc(buf->d, rlen)) == NULL) | 260 | if ((dp = realloc(buf->d, rlen)) == NULL) |
261 | return SSH_ERR_ALLOC_FAIL; | 261 | return SSH_ERR_ALLOC_FAIL; |