mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
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> (cherry picked from commit 654e353d9b20f10fa275e7ae10cc50480654f079)
This commit is contained in:
parent
21fdef6963
commit
ebd434a45e
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user