[git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-48-g5c150ec

by Dmitry Eremin-Solenikov cvs at cvs.gnupg.org
Mon Jan 27 14:35:36 CET 2014


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 crypto library".

The branch, master has been updated
       via  5c150ece094bf0a504a111ce6c7b72e8d0b0457a (commit)
       via  6d87e6abdfb7552323a95401f14e6367398a3e5a (commit)
      from  5d23e7b9a77421f3ebfda4a84c459a8729f3bb41 (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 5c150ece094bf0a504a111ce6c7b72e8d0b0457a
Author: Dmitry Eremin-Solenikov <dbaryshkov at gmail.com>
Date:   Sat Jan 25 03:21:39 2014 +0400

    Fix most of memory leaks in tests code
    
    * tests/basic.c (check_ccm_cipher): Close cipher after use.
    * tests/basic.c (check_one_cipher): Correct length of used buffer.
    * tests/benchmark.c (cipher_bench): Use xcalloc to make buffer
      initialized.
    * tests/keygen.c (check_ecc_keys): Release generated key.
    * tests/t-mpi-point.c (context_param): Release mpi Q.
    * tests/t-sexp.c (check_extract_param): Release extracted number.
    
    --
    The only remaining reported memory leak is one expected leak from
    mpitests.c.
    
    Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov at gmail.com>

diff --git a/tests/basic.c b/tests/basic.c
index e85e4e1..4474a9d 100644
--- a/tests/basic.c
+++ b/tests/basic.c
@@ -2213,6 +2213,8 @@ check_ccm_cipher (void)
 
     if (memcmp (buf, tag, taglen) != 0)
       fail ("cipher-ccm-large, encrypt mismatch entry\n");
+
+    gcry_cipher_close (hde);
   }
 
 #if 0
@@ -2305,6 +2307,8 @@ check_ccm_cipher (void)
 
     if (memcmp (buf, tag, taglen) != 0)
       fail ("cipher-ccm-huge, encrypt mismatch entry\n");
+
+    gcry_cipher_close (hde);
   }
 
   if (verbose)
@@ -3496,7 +3500,7 @@ check_one_cipher (int algo, int mode, int flags)
         return;
 
       /* Pass 2: Key not aligned and data not aligned.  */
-      memmove (plain+1, plain, 1024);
+      memmove (plain+1, plain, 1040);
       if (check_one_cipher_core (algo, mode, flags, key+1, 32, plain+1, 1040,
                                  bufshift, 2+10*bufshift))
         return;
diff --git a/tests/benchmark.c b/tests/benchmark.c
index e009c22..5efc083 100644
--- a/tests/benchmark.c
+++ b/tests/benchmark.c
@@ -656,7 +656,7 @@ cipher_bench ( const char *algoname )
     }
   repetitions *= cipher_repetitions;
 
-  raw_buf = gcry_xmalloc (allocated_buflen+15);
+  raw_buf = gcry_xcalloc (allocated_buflen+15, 1);
   buf = (raw_buf
          + ((16 - ((size_t)raw_buf & 0x0f)) % buffer_alignment));
   outbuf = raw_outbuf = gcry_xmalloc (allocated_buflen+15);
diff --git a/tests/keygen.c b/tests/keygen.c
index e8cf7c5..4aff9c9 100644
--- a/tests/keygen.c
+++ b/tests/keygen.c
@@ -413,6 +413,7 @@ check_ecc_keys (void)
     show_sexp ("ECC key:\n", key);
 
   check_generated_ecc_key (key);
+  gcry_sexp_release (key);
 
   if (verbose)
     show ("creating ECC key using curve Ed25519 for ECDSA (nocomp)\n");
diff --git a/tests/mpitests.c b/tests/mpitests.c
index 9d1206e..d75aca9 100644
--- a/tests/mpitests.c
+++ b/tests/mpitests.c
@@ -212,6 +212,7 @@ test_opaque (void)
 
   if (debug)
     gcry_log_debugmpi ("mpi", a);
+  gcry_mpi_release (a);
 
   p = gcry_xstrdup ("This is a test buffer");
   a = gcry_mpi_set_opaque_copy (NULL, p, 21*8+1);
diff --git a/tests/t-mpi-point.c b/tests/t-mpi-point.c
index d60b3f0..88bb5bd 100644
--- a/tests/t-mpi-point.c
+++ b/tests/t-mpi-point.c
@@ -601,6 +601,7 @@ context_param (void)
       if (err)
         fail ("setting Q for nistp256 failed: %s\n", gpg_strerror (err));
       get_and_cmp_mpi ("q", sample_p256_q, "nistp256(2)", ctx);
+      gcry_mpi_release (q);
 
       /* Get as s-expression.  */
       err = gcry_pubkey_get_sexp (&sexp, 0, ctx);
diff --git a/tests/t-sexp.c b/tests/t-sexp.c
index ec8b280..4c48277 100644
--- a/tests/t-sexp.c
+++ b/tests/t-sexp.c
@@ -1035,6 +1035,7 @@ check_extract_param (void)
       gcry_log_debugmpi ("     got", mpis[0]);
     }
 
+  gcry_free (ioarray[0].data);
   gcry_mpi_release (mpis[0]);
 
   gcry_sexp_release (sxp);

commit 6d87e6abdfb7552323a95401f14e6367398a3e5a
Author: Dmitry Eremin-Solenikov <dbaryshkov at gmail.com>
Date:   Sat Jan 25 03:21:38 2014 +0400

    Fix memory leaks in ecc code
    
    * cipher/ecc-curves.c (_gcry_ecc_update_curve_param): Release passed mpi
      values.
    * cipher/ecc.c (compute_keygrip): Fix potential memory leak in error
      path.
    * cipher/ecc.c (_gcry_ecc_get_curve): Release temporary mpi.
    
    --
    ==11657== 252 (80 direct, 172 indirect) bytes in 4 blocks are definitely lost in loss record 8 of 8
    ==11657==    at 0x4028A28: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
    ==11657==    by 0x404178F: _gcry_private_malloc (stdmem.c:113)
    ==11657==    by 0x403CED1: do_malloc.constprop.4 (global.c:768)
    ==11657==    by 0x403DD01: _gcry_xmalloc (global.c:790)
    ==11657==    by 0x409EAE0: _gcry_mpi_alloc (mpiutil.c:84)
    ==11657==    by 0x409C4E4: _gcry_mpi_scan (mpicoder.c:466)
    ==11657==    by 0x404009C: _gcry_sexp_nth_mpi (sexp.c:796)
    ==11657==    by 0x40410B5: _gcry_sexp_vextract_param (sexp.c:2327)
    ==11657==    by 0x4041396: _gcry_sexp_extract_param (sexp.c:2378)
    ==11657==    by 0x407B895: compute_keygrip (ecc.c:1492)
    ==11657==    by 0x404BBE8: _gcry_pk_get_keygrip (pubkey.c:674)
    ==11657==    by 0x403B1BF: gcry_pk_get_keygrip (visibility.c:1056)
    
    ==16502== 144 (60 direct, 84 indirect) bytes in 3 blocks are definitely lost in loss record 3 of 7
    ==16502==    at 0x4028A28: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
    ==16502==    by 0x404B4DE: _gcry_private_malloc (stdmem.c:113)
    ==16502==    by 0x404667B: do_malloc (global.c:768)
    ==16502==    by 0x40466E7: _gcry_malloc (global.c:790)
    ==16502==    by 0x4046A55: _gcry_xmalloc (global.c:944)
    ==16502==    by 0x40CD25B: _gcry_mpi_alloc (mpiutil.c:84)
    ==16502==    by 0x40CAC3E: _gcry_mpi_scan (mpicoder.c:548)
    ==16502==    by 0x40A72B2: scanval (ecc-curves.c:432)
    ==16502==    by 0x40A7B0D: _gcry_ecc_get_curve (ecc-curves.c:685)
    ==16502==    by 0x4058164: _gcry_pk_get_curve (pubkey.c:747)
    ==16502==    by 0x4043E14: gcry_pk_get_curve (visibility.c:1067)
    ==16502==    by 0x8048934: check_matching (curves.c:124)
    
    Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov at gmail.com>

diff --git a/cipher/ecc-curves.c b/cipher/ecc-curves.c
index dc74ee0..0f622f7 100644
--- a/cipher/ecc-curves.c
+++ b/cipher/ecc-curves.c
@@ -575,6 +575,7 @@ _gcry_ecc_update_curve_param (const char *name,
         return gpg_err_code_from_syserror ();
       strcpy (stpcpy (stpcpy (buf, "0x04"), domain_parms[idx].g_x+2),
               domain_parms[idx].g_y+2);
+      _gcry_mpi_release (*g);
       *g = scanval (buf);
       xfree (buf);
     }
@@ -583,13 +584,25 @@ _gcry_ecc_update_curve_param (const char *name,
   if (dialect)
     *dialect = domain_parms[idx].dialect;
   if (p)
-    *p = scanval (domain_parms[idx].p);
+    {
+      _gcry_mpi_release (*p);
+      *p = scanval (domain_parms[idx].p);
+    }
   if (a)
-    *a = scanval (domain_parms[idx].a);
+    {
+      _gcry_mpi_release (*a);
+      *a = scanval (domain_parms[idx].a);
+    }
   if (b)
-    *b = scanval (domain_parms[idx].b);
+    {
+      _gcry_mpi_release (*b);
+      *b = scanval (domain_parms[idx].b);
+    }
   if (n)
-    *n = scanval (domain_parms[idx].n);
+    {
+      _gcry_mpi_release (*n);
+      *n = scanval (domain_parms[idx].n);
+    }
   return 0;
 }
 
@@ -669,6 +682,7 @@ _gcry_ecc_get_curve (gcry_sexp_t keyparms, int iterator, unsigned int *r_nbits)
 
   for (idx = 0; domain_parms[idx].desc; idx++)
     {
+      mpi_free (tmp);
       tmp = scanval (domain_parms[idx].p);
       if (!mpi_cmp (tmp, E.p))
         {
diff --git a/cipher/ecc.c b/cipher/ecc.c
index 0e5776c..e0be2d4 100644
--- a/cipher/ecc.c
+++ b/cipher/ecc.c
@@ -1520,7 +1520,7 @@ compute_keygrip (gcry_md_hd_t md, gcry_sexp_t keyparms)
                                              &values[0], &values[1], &values[2],
                                              &values[3], &values[4]);
           if (rc)
-            return rc;
+            goto leave;
         }
     }
 

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

Summary of changes:
 cipher/ecc-curves.c |   22 ++++++++++++++++++----
 cipher/ecc.c        |    2 +-
 tests/basic.c       |    6 +++++-
 tests/benchmark.c   |    2 +-
 tests/keygen.c      |    1 +
 tests/mpitests.c    |    1 +
 tests/t-mpi-point.c |    1 +
 tests/t-sexp.c      |    1 +
 8 files changed, 29 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
The GNU crypto library
http://git.gnupg.org


_______________________________________________
Gnupg-commits mailing list
Gnupg-commits at gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-commits




More information about the Gcrypt-devel mailing list