diff options
| author | jsing <> | 2022-11-30 02:52:25 +0000 |
|---|---|---|
| committer | jsing <> | 2022-11-30 02:52:25 +0000 |
| commit | 75e4367c588b97f1dcf3b7acd009e84c3797770d (patch) | |
| tree | 35f9b474173af30978ea782ada13fc14bbc22710 /src | |
| parent | 0023b74fffd159a8c3a8ffb3cee4ff84ef2e9df7 (diff) | |
| download | openbsd-75e4367c588b97f1dcf3b7acd009e84c3797770d.tar.gz openbsd-75e4367c588b97f1dcf3b7acd009e84c3797770d.tar.bz2 openbsd-75e4367c588b97f1dcf3b7acd009e84c3797770d.zip | |
Fix return values bug in BN_ucmp().
BN_ucmp() is supposed to return -1/0/1 on a < b, a == b and a > b, however
it currently returns other negative and positive values when the top of
a and b differ. Correct this.
ok tb@
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/bn/bn_lib.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c index 0ac3977c19..df43da5db6 100644 --- a/src/lib/libcrypto/bn/bn_lib.c +++ b/src/lib/libcrypto/bn/bn_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_lib.c,v 1.64 2022/11/30 01:47:19 jsing Exp $ */ | 1 | /* $OpenBSD: bn_lib.c,v 1.65 2022/11/30 02:52:25 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -691,9 +691,11 @@ BN_ucmp(const BIGNUM *a, const BIGNUM *b) | |||
| 691 | BN_ULONG t1, t2, *ap, *bp; | 691 | BN_ULONG t1, t2, *ap, *bp; |
| 692 | 692 | ||
| 693 | 693 | ||
| 694 | i = a->top - b->top; | 694 | if (a->top < b->top) |
| 695 | if (i != 0) | 695 | return -1; |
| 696 | return (i); | 696 | if (a->top > b->top) |
| 697 | return 1; | ||
| 698 | |||
| 697 | ap = a->d; | 699 | ap = a->d; |
| 698 | bp = b->d; | 700 | bp = b->d; |
| 699 | for (i = a->top - 1; i >= 0; i--) { | 701 | for (i = a->top - 1; i >= 0; i--) { |
