aboutsummaryrefslogtreecommitdiffstats
path: root/g10/compress.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2018-05-13 11:29:40 +0000
committerWerner Koch <[email protected]>2018-05-13 11:29:40 +0000
commit7b7576637ddfb6e426e77a86b05af6d828e585d5 (patch)
tree21919eed435194f8db1dac8150b581a731a66e26 /g10/compress.c
parentdoc: Include release info from 2.2.6 (diff)
parentdoc: Fix URL in NEWS. (diff)
downloadgnupg-7b7576637ddfb6e426e77a86b05af6d828e585d5.tar.gz
gnupg-7b7576637ddfb6e426e77a86b05af6d828e585d5.zip
Merge branch 'STABLE-BRANCH-2-2' into master
-- Resolved Conflicts: NEWS - removed configure.ac - removed Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/compress.c')
-rw-r--r--g10/compress.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/g10/compress.c b/g10/compress.c
index 61bb756f2..e7a6f2b11 100644
--- a/g10/compress.c
+++ b/g10/compress.c
@@ -309,15 +309,19 @@ int
handle_compressed (ctrl_t ctrl, void *procctx, PKT_compressed *cd,
int (*callback)(IOBUF, void *), void *passthru )
{
- compress_filter_context_t *cfx;
int rc;
if(check_compress_algo(cd->algorithm))
return GPG_ERR_COMPR_ALGO;
- cfx = xmalloc_clear (sizeof *cfx);
- cfx->release = release_context;
- cfx->algo = cd->algorithm;
- push_compress_filter(cd->buf,cfx,cd->algorithm);
+ if(cd->algorithm) {
+ compress_filter_context_t *cfx;
+
+ cfx = xmalloc_clear (sizeof *cfx);
+ cfx->release = release_context;
+ cfx->algo = cd->algorithm;
+ if (push_compress_filter(cd->buf, cfx, cd->algorithm))
+ xfree (cfx);
+ }
if( callback )
rc = callback(cd->buf, passthru );
else
@@ -326,16 +330,20 @@ handle_compressed (ctrl_t ctrl, void *procctx, PKT_compressed *cd,
return rc;
}
-void
+gpg_error_t
push_compress_filter(IOBUF out,compress_filter_context_t *zfx,int algo)
{
- push_compress_filter2(out,zfx,algo,0);
+ return push_compress_filter2(out,zfx,algo,0);
}
-void
+
+/* Push a compress filter and return 0 if that succeeded. */
+gpg_error_t
push_compress_filter2(IOBUF out,compress_filter_context_t *zfx,
int algo,int rel)
{
+ gpg_error_t err = gpg_error (GPG_ERR_FALSE);
+
if(algo>=0)
zfx->algo=algo;
else
@@ -350,16 +358,20 @@ push_compress_filter2(IOBUF out,compress_filter_context_t *zfx,
case COMPRESS_ALGO_ZIP:
case COMPRESS_ALGO_ZLIB:
iobuf_push_filter2(out,compress_filter,zfx,rel);
+ err = 0;
break;
#endif
#ifdef HAVE_BZIP2
case COMPRESS_ALGO_BZIP2:
iobuf_push_filter2(out,compress_filter_bz2,zfx,rel);
+ err = 0;
break;
#endif
default:
BUG();
}
+
+ return err;
}