summaryrefslogtreecommitdiff
path: root/mpi/mpiutil.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2013-08-08 15:16:48 +0200
committerWerner Koch <wk@gnupg.org>2013-08-08 15:17:27 +0200
commit426cbc9feca0c8f46208fb3670adab95f9e46087 (patch)
tree5c68e2917c9cffcd53d875e5445caa6eaf2bd07c /mpi/mpiutil.c
parentcc082642c1b0f2a3e9ca78e1ffd3f64417c204bd (diff)
downloadlibgcrypt-426cbc9feca0c8f46208fb3670adab95f9e46087.tar.gz
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@gnupg.org>
Diffstat (limited to 'mpi/mpiutil.c')
-rw-r--r--mpi/mpiutil.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/mpi/mpiutil.c b/mpi/mpiutil.c
index cff15b74..a65d2361 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;
}