From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: David Howells <dhowells@redhat.com>,
Rusty Russell <rusty@rustcorp.com.au>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] MPILIB: Fix comparison of negative MPIs
Date: Sat, 6 Dec 2014 01:00:41 +0100 [thread overview]
Message-ID: <1417824042-539-1-git-send-email-linux@rasmusvillemoes.dk> (raw)
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>
---
lib/mpi/mpi-cmp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/mpi/mpi-cmp.c b/lib/mpi/mpi-cmp.c
index 1871e7b61ca0..3801694240d8 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);
--
2.1.3
next reply other threads:[~2014-12-06 0:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-06 0:00 Rasmus Villemoes [this message]
2014-12-06 0:00 ` [PATCH 2/2] MPILIB: Deobfuscate mpi_cmp Rasmus Villemoes
2015-01-09 11:00 ` David Howells
2015-01-10 10:29 ` [Keyrings] " Dmitry Kasatkin
2015-01-12 11:43 ` David Howells
2015-01-12 11:47 ` Dmitry Kasatkin
2015-01-09 10:58 ` [PATCH 1/2] MPILIB: Fix comparison of negative MPIs David Howells
2015-01-10 10:27 ` [Keyrings] " Dmitry Kasatkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1417824042-539-1-git-send-email-linux@rasmusvillemoes.dk \
--to=linux@rasmusvillemoes.dk \
--cc=dhowells@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox