diff options
author | Rasmus Villemoes <linux@rasmusvillemoes.dk> | 2015-01-14 11:10:12 -0500 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2015-01-14 11:10:12 -0500 |
commit | b9f918a31d629e99c9ca3d6ac2a2d7a905715c69 (patch) | |
tree | baaca0718341de9349805593023944b62336122a /lib/mpi | |
parent | 98dbbcba1b0c1874b9faf9c77b83f9729360aa2c (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 8ed36b8cbe02..d25e9e96c310 100644 --- a/lib/mpi/mpi-cmp.c +++ b/lib/mpi/mpi-cmp.c | |||
@@ -57,7 +57,7 @@ int mpi_cmp(MPI u, MPI v) | |||
57 | if (usize != vsize && !u->sign && !v->sign) | 57 | if (usize != vsize && !u->sign && !v->sign) |
58 | return usize - vsize; | 58 | return usize - vsize; |
59 | if (usize != vsize && u->sign && v->sign) | 59 | if (usize != vsize && u->sign && v->sign) |
60 | return vsize + usize; | 60 | return vsize - usize; |
61 | if (!usize) | 61 | if (!usize) |
62 | return 0; | 62 | return 0; |
63 | cmp = mpihelp_cmp(u->d, v->d, usize); | 63 | cmp = mpihelp_cmp(u->d, v->d, usize); |