diff options
author | jsing <> | 2023-03-11 14:14:54 +0000 |
---|---|---|
committer | jsing <> | 2023-03-11 14:14:54 +0000 |
commit | 59b001c526ef4e52cd2839197c67232fdbe58557 (patch) | |
tree | de6f40c05762f63ac2dc53094c62fa77e2b57cda /src/lib | |
parent | 2169aa7d8fb1fca93b35610fe1cce79730752235 (diff) | |
download | openbsd-59b001c526ef4e52cd2839197c67232fdbe58557.tar.gz openbsd-59b001c526ef4e52cd2839197c67232fdbe58557.tar.bz2 openbsd-59b001c526ef4e52cd2839197c67232fdbe58557.zip |
Avoid -0 in BN_div_word().
Currently, the use of BN_div_word() can result in -0 - avoid this by
setting negative again, at the end of the computation.
Should fix oss-fuzz 56667.
ok tb@
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/bn/bn_word.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lib/libcrypto/bn/bn_word.c b/src/lib/libcrypto/bn/bn_word.c index c900f9ee2e..68d5c2a4b4 100644 --- a/src/lib/libcrypto/bn/bn_word.c +++ b/src/lib/libcrypto/bn/bn_word.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_word.c,v 1.19 2023/03/11 14:13:11 jsing Exp $ */ | 1 | /* $OpenBSD: bn_word.c,v 1.20 2023/03/11 14:14:54 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 | * |
@@ -131,6 +131,10 @@ BN_div_word(BIGNUM *a, BN_ULONG w) | |||
131 | if ((a->top > 0) && (a->d[a->top - 1] == 0)) | 131 | if ((a->top > 0) && (a->d[a->top - 1] == 0)) |
132 | a->top--; | 132 | a->top--; |
133 | ret >>= j; | 133 | ret >>= j; |
134 | |||
135 | /* Set negative again, to handle -0 case. */ | ||
136 | BN_set_negative(a, a->neg); | ||
137 | |||
134 | return (ret); | 138 | return (ret); |
135 | } | 139 | } |
136 | 140 | ||