diff options
| author | Rasmus Villemoes <linux@rasmusvillemoes.dk> | 2015-01-14 16:10:12 +0000 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-04-11 10:59:41 +0200 |
| commit | 14a2cf71d32c298660f18c3b65dabd6ce8a5a011 (patch) | |
| tree | 12aca3b3ebca353aa5af03065c976f0456f99f27 /lib/mpi | |
| parent | 2be47cd0a3dd607963e0ac4524488caab93c1724 (diff) | |
MPILIB: Fix comparison of negative MPIs
If u and v both represent negative integers and their limb counts
happen to differ, mpi_cmp will always return a positive value - this
is obviously bogus. u is smaller than v if and only if it is larger in
absolute value.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Dmitry Kasatkin <dmitry.kasatkin@gmail.com>
Diffstat (limited to 'lib/mpi')
| -rw-r--r-- | lib/mpi/mpi-cmp.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/mpi/mpi-cmp.c b/lib/mpi/mpi-cmp.c index 8ed36b8cb..d25e9e96c 100644 --- a/lib/mpi/mpi-cmp.c +++ b/lib/mpi/mpi-cmp.c @@ -57,7 +57,7 @@ int mpi_cmp(MPI u, MPI v) if (usize != vsize && !u->sign && !v->sign) return usize - vsize; if (usize != vsize && u->sign && v->sign) - return vsize + usize; + return vsize - usize; if (!usize) return 0; cmp = mpihelp_cmp(u->d, v->d, usize); |
