diff options
author | jsing <> | 2022-11-23 03:04:52 +0000 |
---|---|---|
committer | jsing <> | 2022-11-23 03:04:52 +0000 |
commit | bc4574576aa870ae46b89eb9506a76cdccea8db2 (patch) | |
tree | a5807adb02a41e094eba21805a53f33d802024c7 | |
parent | 7b09303e41bcba8067b9975f2c3fa8ad2ef3fc33 (diff) | |
download | openbsd-bc4574576aa870ae46b89eb9506a76cdccea8db2.tar.gz openbsd-bc4574576aa870ae46b89eb9506a76cdccea8db2.tar.bz2 openbsd-bc4574576aa870ae46b89eb9506a76cdccea8db2.zip |
Ensure that bn_expand()/bn_wexpand() fail on negative sizes.
ok tb@
-rw-r--r-- | src/lib/libcrypto/bn/bn_lib.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c index 7c85e7ad08..15bbdf1273 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.58 2022/11/23 03:00:12 jsing Exp $ */ | 1 | /* $OpenBSD: bn_lib.c,v 1.59 2022/11/23 03:04:52 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 | * |
@@ -377,6 +377,9 @@ bn_expand2(BIGNUM *b, int words) | |||
377 | BIGNUM * | 377 | BIGNUM * |
378 | bn_expand(BIGNUM *a, int bits) | 378 | bn_expand(BIGNUM *a, int bits) |
379 | { | 379 | { |
380 | if (bits < 0) | ||
381 | return (NULL); | ||
382 | |||
380 | if (bits > (INT_MAX - BN_BITS2 + 1)) | 383 | if (bits > (INT_MAX - BN_BITS2 + 1)) |
381 | return (NULL); | 384 | return (NULL); |
382 | 385 | ||
@@ -389,6 +392,9 @@ bn_expand(BIGNUM *a, int bits) | |||
389 | BIGNUM * | 392 | BIGNUM * |
390 | bn_wexpand(BIGNUM *a, int words) | 393 | bn_wexpand(BIGNUM *a, int words) |
391 | { | 394 | { |
395 | if (words < 0) | ||
396 | return NULL; | ||
397 | |||
392 | if (words <= a->dmax) | 398 | if (words <= a->dmax) |
393 | return a; | 399 | return a; |
394 | 400 | ||