summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorjsing <>2022-11-30 02:52:25 +0000
committerjsing <>2022-11-30 02:52:25 +0000
commitc4a74c3795e06bd2bab862ba1b51d811fb3937ef (patch)
tree35f9b474173af30978ea782ada13fc14bbc22710 /src/lib
parent98fdf212aa5e4f2ef06229aa985583515e797eb6 (diff)
downloadopenbsd-c4a74c3795e06bd2bab862ba1b51d811fb3937ef.tar.gz
openbsd-c4a74c3795e06bd2bab862ba1b51d811fb3937ef.tar.bz2
openbsd-c4a74c3795e06bd2bab862ba1b51d811fb3937ef.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/lib')
-rw-r--r--src/lib/libcrypto/bn/bn_lib.c10
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--) {