[git] GCRYPT - branch, LIBGCRYPT-1-6-BRANCH, updated. libgcrypt-1.6.0-18-g41cc0f7

by Dmitry Eremin-Solenikov cvs at cvs.gnupg.org
Mon Jan 27 14:53:30 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, LIBGCRYPT-1-6-BRANCH has been updated
       via  41cc0f72e6c964eb20a2decaa4ea61776c511d96 (commit)
       via  48cc151e9a6372b82a3e8ba03c271b93d783a411 (commit)
       via  a180117d20ec36ac89bbe33e210358fcfb18ac2a (commit)
      from  04d478d9b0f92d80105ddaf2c011f40ae8260cfb (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 41cc0f72e6c964eb20a2decaa4ea61776c511d96
Author: Dmitry Eremin-Solenikov <dbaryshkov at gmail.com>
Date:   Fri Jan 24 15:02:15 2014 +0400

    tests: Pass -no-install to libtool
    
    * tests/Makefile.am: add AM_LDFLAGS = -no-install
    
    --
    There is little point building tests with support for installation.
    Passing -no-install stops libtool from building wrapper scripts,
    thus allowing direct gdb/valgrind invocation on programs in tests/
    subdirectory.
    
    Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov at gmail.com>
    (cherry picked from commit bf34bfa5c458ee5ece91f25e3b4194d768498ab6)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 99d3ecd..6cde99f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -44,6 +44,7 @@ TESTS_ENVIRONMENT = GCRYPT_IN_REGRESSION_TEST=1
 # a built header.
 AM_CPPFLAGS = -I../src -I$(top_srcdir)/src
 AM_CFLAGS = $(GPG_ERROR_CFLAGS)
+AM_LDFLAGS = -no-install
 
 default_ldadd = \
 	../src/libgcrypt.la $(DL_LIBS) \

commit 48cc151e9a6372b82a3e8ba03c271b93d783a411
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>
    (cherry picked from commit 5c150ece094bf0a504a111ce6c7b72e8d0b0457a)

diff --git a/tests/basic.c b/tests/basic.c
index 97276d0..bebfa67 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 ae52601..5ab0598 100644
--- a/tests/t-mpi-point.c
+++ b/tests/t-mpi-point.c
@@ -611,6 +611,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/tsexp.c b/tests/tsexp.c
index 1ab9802..704f9b1 100644
--- a/tests/tsexp.c
+++ b/tests/tsexp.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 a180117d20ec36ac89bbe33e210358fcfb18ac2a
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>
    (cherry picked from commit 6d87e6abdfb7552323a95401f14e6367398a3e5a)

diff --git a/cipher/ecc-curves.c b/cipher/ecc-curves.c
index ed629fc..41adfd1 100644
--- a/cipher/ecc-curves.c
+++ b/cipher/ecc-curves.c
@@ -473,6 +473,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);
     }
@@ -481,13 +482,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;
 }
 
@@ -567,6 +580,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 06bfb47..debb71b 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/Makefile.am   |    1 +
 tests/basic.c       |    6 +++++-
 tests/benchmark.c   |    2 +-
 tests/keygen.c      |    1 +
 tests/mpitests.c    |    1 +
 tests/t-mpi-point.c |    1 +
 tests/tsexp.c       |    1 +
 9 files changed, 30 insertions(+), 7 deletions(-)


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




More information about the Gnupg-commits mailing list