diff options
author | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2018-12-01 12:43:10 +0100 |
---|---|---|
committer | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2018-12-01 12:43:10 +0100 |
commit | 654e353d9b20f10fa275e7ae10cc50480654f079 (patch) | |
tree | 50af13e1418158c5de8c9eaab7aeebf72e2ea898 /common | |
parent | common/mischelp: use platform memory zeroing function for wipememory (diff) | |
download | gnupg2-654e353d9b20f10fa275e7ae10cc50480654f079.tar.xz gnupg2-654e353d9b20f10fa275e7ae10cc50480654f079.zip |
common/iobuf: fix memory wiping in iobuf_copy
* common/iobuf.c (iobuf_copy): Wipe used area of buffer instead of
first sizeof(char*) bytes.
--
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to '')
-rw-r--r-- | common/iobuf.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/common/iobuf.c b/common/iobuf.c index 5eeba8fe6..05944255f 100644 --- a/common/iobuf.c +++ b/common/iobuf.c @@ -2262,6 +2262,7 @@ iobuf_copy (iobuf_t dest, iobuf_t source) size_t nread; size_t nwrote = 0; + size_t max_read = 0; int err; assert (source->use == IOBUF_INPUT || source->use == IOBUF_INPUT_TEMP); @@ -2278,6 +2279,9 @@ iobuf_copy (iobuf_t dest, iobuf_t source) /* EOF. */ break; + if (nread > max_read) + max_read = nread; + err = iobuf_write (dest, temp, nread); if (err) break; @@ -2285,7 +2289,8 @@ iobuf_copy (iobuf_t dest, iobuf_t source) } /* Burn the buffer. */ - wipememory (temp, sizeof (temp)); + if (max_read) + wipememory (temp, max_read); xfree (temp); return nwrote; |