diff options
| author | jsing <> | 2022-11-23 03:04:52 +0000 |
|---|---|---|
| committer | jsing <> | 2022-11-23 03:04:52 +0000 |
| commit | 61495bb782b6a6d7e16abbc01c401cec403c672c (patch) | |
| tree | a5807adb02a41e094eba21805a53f33d802024c7 /src | |
| parent | c156153a0e2e163fd43e7a160346dcb3b05e5ad8 (diff) | |
| download | openbsd-61495bb782b6a6d7e16abbc01c401cec403c672c.tar.gz openbsd-61495bb782b6a6d7e16abbc01c401cec403c672c.tar.bz2 openbsd-61495bb782b6a6d7e16abbc01c401cec403c672c.zip | |
Ensure that bn_expand()/bn_wexpand() fail on negative sizes.
ok tb@
Diffstat (limited to '')
| -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 | ||
