[git] GnuPG - branch, STABLE-BRANCH-2-2, updated. gnupg-2.2.6-40-gd26363e

by Werner Koch cvs at cvs.gnupg.org
Wed May 2 20:29:10 CEST 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, STABLE-BRANCH-2-2 has been updated
       via  d26363e4f1933781c86cbe87077fbf1b9a2b64d8 (commit)
      from  f7f3043653abe699602f910ddd09c1405675c7f6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit d26363e4f1933781c86cbe87077fbf1b9a2b64d8
Author: Werner Koch <wk at gnupg.org>
Date:   Wed May 2 19:44:10 2018 +0200

    gpg: Fix minor memory leak in the compress filter.
    
    * g10/compress.c (push_compress_filter2): Return an error if no filter
    was pushed.
    (push_compress_filter): Ditto.
    (handle_compressed): Free CFX if no filter was pushed.
    * g10/import.c (read_block): Ditto.
    --
    
    GnuPG-bug-id: 3898, 3930
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/g10/compress.c b/g10/compress.c
index 67c9c9b..e7a6f2b 100644
--- a/g10/compress.c
+++ b/g10/compress.c
@@ -319,7 +319,8 @@ handle_compressed (ctrl_t ctrl, void *procctx, PKT_compressed *cd,
         cfx = xmalloc_clear (sizeof *cfx);
         cfx->release = release_context;
         cfx->algo = cd->algorithm;
-        push_compress_filter(cd->buf,cfx,cd->algorithm);
+        if (push_compress_filter(cd->buf, cfx, cd->algorithm))
+          xfree (cfx);
     }
     if( callback )
 	rc = callback(cd->buf, passthru );
@@ -329,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
@@ -353,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;
 }
diff --git a/g10/filter.h b/g10/filter.h
index 9e4b1e5..2c1e513 100644
--- a/g10/filter.h
+++ b/g10/filter.h
@@ -140,9 +140,10 @@ void        unarmor_pump_release (UnarmorPump x);
 int         unarmor_pump (UnarmorPump x, int c);
 
 /*-- compress.c --*/
-void push_compress_filter(iobuf_t out,compress_filter_context_t *zfx,int algo);
-void push_compress_filter2(iobuf_t out,compress_filter_context_t *zfx,
-			   int algo,int rel);
+gpg_error_t push_compress_filter (iobuf_t out, compress_filter_context_t *zfx,
+                                  int algo);
+gpg_error_t push_compress_filter2 (iobuf_t out,compress_filter_context_t *zfx,
+                                   int algo, int rel);
 
 /*-- cipher.c --*/
 int cipher_filter( void *opaque, int control,
diff --git a/g10/import.c b/g10/import.c
index 71e3955..c07f67f 100644
--- a/g10/import.c
+++ b/g10/import.c
@@ -767,7 +767,7 @@ valid_keyblock_packet (int pkttype)
  * Meta data (ring trust packets) are only considered of WITH_META is set.
  * PENDING_PKT should be initialized to NULL and not changed by the caller.
  * Return: 0 = okay, -1 no more blocks or another errorcode.
- *         The int at at R_V3KEY counts the number of unsupported v3
+ *         The int at R_V3KEY counts the number of unsupported v3
  *         keyblocks.
  */
 static int
@@ -856,7 +856,9 @@ read_block( IOBUF a, int with_meta,
 	      {
 		compress_filter_context_t *cfx = xmalloc_clear( sizeof *cfx );
 		pkt->pkt.compressed->buf = NULL;
-		push_compress_filter2(a,cfx,pkt->pkt.compressed->algorithm,1);
+		if (push_compress_filter2 (a, cfx,
+                                           pkt->pkt.compressed->algorithm, 1))
+                  xfree (cfx); /* e.g. in case of compression_algo NONE.  */
 	      }
 	    free_packet (pkt, &parsectx);
 	    init_packet(pkt);

-----------------------------------------------------------------------

Summary of changes:
 g10/compress.c | 17 +++++++++++++----
 g10/filter.h   |  7 ++++---
 g10/import.c   |  6 ++++--
 3 files changed, 21 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list