summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2020-07-06 12:01:42 +0200
committerWerner Koch <wk@gnupg.org>2020-07-06 12:01:42 +0200
commit1f3a92e103d4a8e019d8d022647a2b9fb2681327 (patch)
treef64efc69b0e9fa5d1282ecc556b45ec2baf5b42e
parent1db1dc7945b111b6e20a8420ad38a358316681ab (diff)
downloadlibgcrypt-1f3a92e103d4a8e019d8d022647a2b9fb2681327.tar.gz
mpi: Consider +0 and -0 the same in mpi_cmp.
* mpi/mpi-cmp.c (do_mpi_cmp): Check size of U an V. Signed-off-by: Werner Koch <wk@gnupg.org>
-rw-r--r--mpi/mpi-cmp.c5
-rw-r--r--mpi/mpiutil.c2
2 files changed, 5 insertions, 2 deletions
diff --git a/mpi/mpi-cmp.c b/mpi/mpi-cmp.c
index 66e09612..8927fa0e 100644
--- a/mpi/mpi-cmp.c
+++ b/mpi/mpi-cmp.c
@@ -89,8 +89,11 @@ do_mpi_cmp (gcry_mpi_t u, gcry_mpi_t v, int absmode)
usign = absmode? 0 : u->sign;
vsign = absmode? 0 : v->sign;
- /* Compare sign bits. */
+ /* Special treatment for +0 == -0 */
+ if (!usize && !vsize)
+ return 0;
+ /* Compare sign bits. */
if (!usign && vsign)
return 1;
if (usign && !vsign)
diff --git a/mpi/mpiutil.c b/mpi/mpiutil.c
index a9e812e2..86b8361e 100644
--- a/mpi/mpiutil.c
+++ b/mpi/mpiutil.c
@@ -561,7 +561,7 @@ _gcry_mpi_set_ui (gcry_mpi_t w, unsigned long u)
* int so that the value can be used with the bit test functions; in
* contrast the other _ui functions take an unsigned long so that on
* some platforms they may accept a larger value. On error the value
- * at U is not changed. */
+ * at W is not changed. */
gcry_err_code_t
_gcry_mpi_get_ui (unsigned int *w, gcry_mpi_t u)
{