public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: dhowells@redhat.com, Rusty Russell <rusty@rustcorp.com.au>,
	d.kasatkin@samsung.com, linux-kernel@vger.kernel.org,
	keyrings@linux-nfs.org
Subject: Re: [PATCH 1/2] MPILIB: Fix comparison of negative MPIs
Date: Fri, 09 Jan 2015 10:58:01 +0000	[thread overview]
Message-ID: <2180.1420801081@warthog.procyon.org.uk> (raw)
In-Reply-To: <1417824042-539-1-git-send-email-linux@rasmusvillemoes.dk>

I think you're right - *adding* the two sizes makes no sense.  cc'ing Dmitry
also for his check.

David


Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote:

> 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
> 

  parent reply	other threads:[~2015-01-09 10:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-06  0:00 [PATCH 1/2] MPILIB: Fix comparison of negative MPIs Rasmus Villemoes
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 ` David Howells [this message]
2015-01-10 10:27   ` [Keyrings] [PATCH 1/2] MPILIB: Fix comparison of negative MPIs 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=2180.1420801081@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=d.kasatkin@samsung.com \
    --cc=keyrings@linux-nfs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --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