aboutsummaryrefslogtreecommitdiffstats
path: root/common/iobuf.c
diff options
context:
space:
mode:
authorJussi Kivilinna <[email protected]>2022-02-12 18:37:48 +0000
committerJussi Kivilinna <[email protected]>2022-03-08 18:00:31 +0000
commitf2322ff942fabd55de0a1272b1fcca534e623bd1 (patch)
tree06d299bec082d33231ef80688e83de4a0649c20f /common/iobuf.c
parentgpgtar,w32: Support file names longer than MAX_PATH. (diff)
downloadgnupg-f2322ff942fabd55de0a1272b1fcca534e623bd1.tar.gz
gnupg-f2322ff942fabd55de0a1272b1fcca534e623bd1.zip
Use iobuf buffer size for temporary buffer size
* common/iobuf.c (iobuf_copy): Use iobuf buffer size for temporary buffers. * g10/plaintext.c (handle_plaintext, do_hash): Likewise. * g10/sign.c (sign_file): Likewise. -- As iobuf will have zerocopy operation for read/write, it is better to use same size buffers as iobuf for temporary copy buffers. GnuPG-bug-id: T5828 Signed-off-by: Jussi Kivilinna <[email protected]>
Diffstat (limited to 'common/iobuf.c')
-rw-r--r--common/iobuf.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/common/iobuf.c b/common/iobuf.c
index ace745542..822eabe1a 100644
--- a/common/iobuf.c
+++ b/common/iobuf.c
@@ -2298,9 +2298,7 @@ size_t
iobuf_copy (iobuf_t dest, iobuf_t source)
{
char *temp;
- /* Use a 32 KB buffer. */
- const size_t temp_size = 32 * 1024;
-
+ size_t temp_size;
size_t nread;
size_t nwrote = 0;
size_t max_read = 0;
@@ -2312,6 +2310,9 @@ iobuf_copy (iobuf_t dest, iobuf_t source)
if (iobuf_error (dest))
return -1;
+ /* Use iobuf buffer size for temporary buffer. */
+ temp_size = iobuf_set_buffer_size(0) * 1024;
+
temp = xmalloc (temp_size);
while (1)
{