From: Rasmus Villemoes Date: Wed, 14 Jan 2015 16:10:12 +0000 (+0000) Subject: MPILIB: Fix comparison of negative MPIs X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b9f918a31d629e99c9ca3d6ac2a2d7a905715c69;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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 Signed-off-by: David Howells Acked-by: Dmitry Kasatkin --- 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) 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);