libgcrypt/mpi (ChangeLog mpiutil.c)
cvs user mo
cvs at cvs.gnupg.org
Wed Feb 16 20:37:54 CET 2005
Date: Wednesday, February 16, 2005 @ 20:48:35
Author: mo
Path: /cvs/libgcrypt/libgcrypt/mpi
Modified: ChangeLog mpiutil.c
2005-02-16 Moritz Schulte <moritz at g10code.com>
* mpiutil.c (_gcry_mpi_alloc_limb_space): Rewritten, fixed memory
corruption.
-----------+
ChangeLog | 9 +++++++++
mpiutil.c | 43 ++++++++++++++++++++++++++++++++++---------
2 files changed, 43 insertions(+), 9 deletions(-)
Index: libgcrypt/mpi/ChangeLog
diff -u libgcrypt/mpi/ChangeLog:1.90 libgcrypt/mpi/ChangeLog:1.91
--- libgcrypt/mpi/ChangeLog:1.90 Thu Dec 16 17:34:56 2004
+++ libgcrypt/mpi/ChangeLog Wed Feb 16 20:48:35 2005
@@ -1,3 +1,12 @@
+2005-02-16 Moritz Schulte <moritz at g10code.com>
+
+ * mpiutil.c (_gcry_mpi_alloc_limb_space): Rewritten, fixed memory
+ corruption.
+
+2005-02-06 Moritz Schulte <moritz at g10code.com>
+
+ * mpiutil.c (_gcry_mpi_get_ui, gcry_mpi_get_ui): New functions.
+
2004-12-16 Werner Koch <wk at g10code.com>
* config.links (mpi_optional_modules): Move entry for powerpc64
Index: libgcrypt/mpi/mpiutil.c
diff -u libgcrypt/mpi/mpiutil.c:1.38 libgcrypt/mpi/mpiutil.c:1.39
--- libgcrypt/mpi/mpiutil.c:1.38 Wed Mar 3 09:08:43 2004
+++ libgcrypt/mpi/mpiutil.c Wed Feb 16 20:48:35 2005
@@ -75,16 +75,13 @@
mpi_ptr_t
_gcry_mpi_alloc_limb_space( unsigned int nlimbs, int secure )
{
- size_t len = nlimbs * sizeof(mpi_limb_t);
- mpi_ptr_t p = NULL;
+ mpi_ptr_t p;
+ size_t len;
- if (!nlimbs)
- {
- p = secure? gcry_xmalloc_secure( 1 ) : gcry_xmalloc( 1 );
- *p = 0;
- }
- else
- p = secure? gcry_xmalloc_secure( len ) : gcry_xmalloc( len );
+ len = (nlimbs ? nlimbs : 1) * sizeof (mpi_limb_t);
+ p = secure ? gcry_xmalloc_secure (len) : gcry_xmalloc (len);
+ if (! nlimbs)
+ *p = 0;
return p;
}
@@ -305,6 +302,34 @@
w->flags = 0;
}
+gcry_err_code_t
+_gcry_mpi_get_ui (gcry_mpi_t w, unsigned long *u)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ unsigned long x = 0;
+
+ if (w->nlimbs > 1)
+ err = GPG_ERR_TOO_LARGE;
+ else if (w->nlimbs == 1)
+ x = w->d[0];
+ else
+ x = 0;
+
+ if (! err)
+ *u = x;
+
+ return err;
+}
+
+gcry_error_t
+gcry_mpi_get_ui (gcry_mpi_t w, unsigned long *u)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+
+ err = _gcry_mpi_get_ui (w, u);
+
+ return gcry_error (err);
+}
gcry_mpi_t
_gcry_mpi_alloc_set_ui( unsigned long u)
More information about the Gnupg-commits
mailing list