diff options
| author | jsing <> | 2023-03-11 14:14:54 +0000 |
|---|---|---|
| committer | jsing <> | 2023-03-11 14:14:54 +0000 |
| commit | 52fd1244f8c53de73ef10d4f9511eee80489d31a (patch) | |
| tree | de6f40c05762f63ac2dc53094c62fa77e2b57cda /src/lib/libc | |
| parent | 0011bd4b5ca21dd631b72942920a62fa4a90fa88 (diff) | |
| download | openbsd-52fd1244f8c53de73ef10d4f9511eee80489d31a.tar.gz openbsd-52fd1244f8c53de73ef10d4f9511eee80489d31a.tar.bz2 openbsd-52fd1244f8c53de73ef10d4f9511eee80489d31a.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 '')
| -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 | ||
