diff options
author | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2022-03-07 19:54:34 +0100 |
---|---|---|
committer | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2022-03-08 19:03:08 +0100 |
commit | 49c6e583945263497064109697237701977689c3 (patch) | |
tree | e5bf38dd097ae3a54927200bf2a20dd0a34a099c | |
parent | iobuf: add zerocopy optimization for iobuf_write (diff) | |
download | gnupg2-49c6e583945263497064109697237701977689c3.tar.xz gnupg2-49c6e583945263497064109697237701977689c3.zip |
gpg: fix --enarmor with zero length source file
* common/iobuf.c (filter_flush): Remove "src_len == 0" check.
* g10/compress-bz2.c (do_compress): Exit early if flush not
forced and input length is zero.
* g10/compress.c (do_compress): Likewise.
--
Remove "(src_len == 0)" check in filter_flush which was
introduced to fix compress failure caused by zero length
flush from iobuf_close. However this check broke enarmoring
file with length of zero. Patch instead fixes zero length
flush problem in compress filters.
GnuPG-bug-id: T5828
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
-rw-r--r-- | common/iobuf.c | 8 | ||||
-rw-r--r-- | g10/compress-bz2.c | 3 | ||||
-rw-r--r-- | g10/compress.c | 3 |
3 files changed, 6 insertions, 8 deletions
diff --git a/common/iobuf.c b/common/iobuf.c index bde6a5ccc..8ec4c86c0 100644 --- a/common/iobuf.c +++ b/common/iobuf.c @@ -2090,14 +2090,6 @@ filter_flush (iobuf_t a) external_used = 0; } - if (src_len == 0) - { - if (DBG_IOBUF) - log_debug ("filter_flush, nothing to flush%s\n", - external_used ? " (external buffer)" : ""); - return 0; - } - len = src_len; rc = a->filter (a->filter_ov, IOBUFCTRL_FLUSH, a->chain, src_buf, &len); if (!rc && len != src_len) diff --git a/g10/compress-bz2.c b/g10/compress-bz2.c index 45aa40dfc..2c3b86f8f 100644 --- a/g10/compress-bz2.c +++ b/g10/compress-bz2.c @@ -66,6 +66,9 @@ do_compress(compress_filter_context_t *zfx, bz_stream *bzs, int flush, IOBUF a) int zrc; unsigned n; + if (flush == BZ_RUN && bzs->avail_in == 0) + return 0; + do { bzs->next_out = zfx->outbuf; diff --git a/g10/compress.c b/g10/compress.c index e7a6f2b11..777ef47fb 100644 --- a/g10/compress.c +++ b/g10/compress.c @@ -100,6 +100,9 @@ do_compress( compress_filter_context_t *zfx, z_stream *zs, int flush, IOBUF a ) int zrc; unsigned n; + if (flush == Z_NO_FLUSH && zs->avail_in == 0) + return 0; + do { zs->next_out = BYTEF_CAST (zfx->outbuf); zs->avail_out = zfx->outbufsize; |