diff options
author | Jussi Kivilinna <[email protected]> | 2018-12-01 11:43:10 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2018-12-05 07:25:48 +0000 |
commit | ebd434a45eefd34bd9d9f875f22a74a47b88dd5f (patch) | |
tree | e8afe904f957896af9d73b080dc82ed49f933959 | |
parent | common: Use platform memory zeroing function for wipememory (diff) | |
download | gnupg-ebd434a45eefd34bd9d9f875f22a74a47b88dd5f.tar.gz gnupg-ebd434a45eefd34bd9d9f875f22a74a47b88dd5f.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 <[email protected]>
(cherry picked from commit 654e353d9b20f10fa275e7ae10cc50480654f079)
-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 8de46f4c3..589bdf9f6 100644 --- a/common/iobuf.c +++ b/common/iobuf.c @@ -2216,6 +2216,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); @@ -2232,6 +2233,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; @@ -2239,7 +2243,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; |