1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

g10/encrypt: use iobuf_copy instead of manual iobuf_read/iobuf_write

* g10/encrypt.c (encrypt_simple): Use 'iobuf_copy' for no-literal case.
--

GnuPG-bug-id: T5852
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
This commit is contained in:
Jussi Kivilinna 2022-02-13 15:09:42 +02:00
parent 9c313321a8
commit 756c0bd5d8

View File

@ -497,15 +497,9 @@ encrypt_simple (const char *filename, int mode, int use_seskey)
{
/* User requested not to create a literal packet, so we copy the
plain data. */
byte copy_buffer[4096];
int bytes_copied;
while ((bytes_copied = iobuf_read(inp, copy_buffer, 4096)) != -1)
if ( (rc=iobuf_write(out, copy_buffer, bytes_copied)) ) {
log_error ("copying input to output failed: %s\n",
gpg_strerror (rc) );
break;
}
wipememory (copy_buffer, 4096); /* burn buffer */
rc = iobuf_copy (out, inp);
if (rc)
log_error ("copying input to output failed: %s\n", gpg_strerror (rc));
}
/* Finish the stuff. */