[git] GCRYPT - branch, master, updated. libgcrypt-1.5.0-184-g426cbc9

by Werner Koch cvs at cvs.gnupg.org
Thu Aug 8 15:48:39 CEST 2013


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  426cbc9feca0c8f46208fb3670adab95f9e46087 (commit)
      from  cc082642c1b0f2a3e9ca78e1ffd3f64417c204bd (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 426cbc9feca0c8f46208fb3670adab95f9e46087
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Aug 8 15:16:48 2013 +0200

    mpi: Clear immutable flag on the result of gcry_mpi_set.
    
    * mpi/mpiutil.c (gcry_mpi_set): Reset immutable and const flags.
    * tests/mpitests.c (test_const_and_immutable): Add a test for this.
    --
    
    gcry_mpi_set shall behave like gcry_mpi_copy and thus reset those
    special flags.  Problem reported by Christian Grothoff.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/mpi/mpiutil.c b/mpi/mpiutil.c
index cff15b7..a65d236 100644
--- a/mpi/mpiutil.c
+++ b/mpi/mpiutil.c
@@ -397,6 +397,7 @@ gcry_mpi_set( gcry_mpi_t w, gcry_mpi_t u)
   MPN_COPY( wp, up, usize );
   w->nlimbs = usize;
   w->flags = u->flags;
+  w->flags &= ~(16|32); /* Reset the immutable and constant flags.  */
   w->sign = usign;
   return w;
 }
diff --git a/tests/mpitests.c b/tests/mpitests.c
index 03c15b9..e1c51d1 100644
--- a/tests/mpitests.c
+++ b/tests/mpitests.c
@@ -143,6 +143,23 @@ test_const_and_immutable (void)
   if (!gcry_mpi_get_flag (one, GCRYMPI_FLAG_CONST))
     die ("const flag unexpectly cleared\n");
 
+
+  second_one = gcry_mpi_set (NULL, GCRYMPI_CONST_ONE);
+  if (gcry_mpi_get_flag (second_one, GCRYMPI_FLAG_IMMUTABLE))
+    die ("immutable flag not cleared by mpi_set (NULL,x)\n");
+  if (gcry_mpi_get_flag (second_one, GCRYMPI_FLAG_CONST))
+    die ("const flag not cleared by mpi_set (NULL,x)\n");
+  gcry_mpi_release (second_one);
+
+  second_one = gcry_mpi_set_ui (NULL, 42);
+  gcry_mpi_set (second_one, GCRYMPI_CONST_ONE);
+  if (gcry_mpi_get_flag (second_one, GCRYMPI_FLAG_IMMUTABLE))
+    die ("immutable flag not cleared after mpi_set (a,x)\n");
+  if (gcry_mpi_get_flag (second_one, GCRYMPI_FLAG_CONST))
+    die ("const flag not cleared mpi_set (a,x)\n");
+  gcry_mpi_release (second_one);
+
+
   /* Due to the the constant flag the release below should be a NOP
      and will leak memory.  */
   gcry_mpi_release (one);

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

Summary of changes:
 mpi/mpiutil.c    |    1 +
 tests/mpitests.c |   17 +++++++++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)


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




More information about the Gnupg-commits mailing list