diff options
| author | tb <> | 2019-01-20 01:59:06 +0000 |
|---|---|---|
| committer | tb <> | 2019-01-20 01:59:06 +0000 |
| commit | ffe325dd96abe81425cd3ab4831c2ee4e33adc17 (patch) | |
| tree | f16b64a06ca4d9aee0483b4ea5dfe9abc4834c54 /src | |
| parent | d5dab9ba75c9c829a61151d8cec3e00e899ad4b6 (diff) | |
| download | openbsd-ffe325dd96abe81425cd3ab4831c2ee4e33adc17.tar.gz openbsd-ffe325dd96abe81425cd3ab4831c2ee4e33adc17.tar.bz2 openbsd-ffe325dd96abe81425cd3ab4831c2ee4e33adc17.zip | |
Fix BN_is_prime_* calls in openssl(1), the API returns -1 on error.
Found thanks to BoringSSL's commit 53409ee3d7595ed37da472bc73b010cd2c8a5ffd
by David Benjamin.
ok djm, jsing
Diffstat (limited to 'src')
| -rw-r--r-- | src/usr.bin/openssl/prime.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/usr.bin/openssl/prime.c b/src/usr.bin/openssl/prime.c index 280ccef5fc..5e1ad70ca0 100644 --- a/src/usr.bin/openssl/prime.c +++ b/src/usr.bin/openssl/prime.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: prime.c,v 1.11 2018/02/07 05:47:55 jsing Exp $ */ | 1 | /* $OpenBSD: prime.c,v 1.12 2019/01/20 01:59:06 tb Exp $ */ |
| 2 | /* ==================================================================== | 2 | /* ==================================================================== |
| 3 | * Copyright (c) 2004 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 2004 The OpenSSL Project. All rights reserved. |
| 4 | * | 4 | * |
| @@ -116,7 +116,7 @@ prime_main(int argc, char **argv) | |||
| 116 | char *prime = NULL; | 116 | char *prime = NULL; |
| 117 | BIO *bio_out; | 117 | BIO *bio_out; |
| 118 | char *s; | 118 | char *s; |
| 119 | int ret = 1; | 119 | int is_prime, ret = 1; |
| 120 | 120 | ||
| 121 | if (single_execution) { | 121 | if (single_execution) { |
| 122 | if (pledge("stdio rpath", NULL) == -1) { | 122 | if (pledge("stdio rpath", NULL) == -1) { |
| @@ -184,9 +184,13 @@ prime_main(int argc, char **argv) | |||
| 184 | } | 184 | } |
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | is_prime = BN_is_prime_ex(bn, prime_config.checks, NULL, NULL); | ||
| 188 | if (is_prime < 0) { | ||
| 189 | BIO_printf(bio_err, "BN_is_prime_ex failed.\n"); | ||
| 190 | goto end; | ||
| 191 | } | ||
| 187 | BIO_printf(bio_out, "%s is %sprime\n", prime, | 192 | BIO_printf(bio_out, "%s is %sprime\n", prime, |
| 188 | BN_is_prime_ex(bn, prime_config.checks, | 193 | is_prime == 1 ? "" : "not "); |
| 189 | NULL, NULL) ? "" : "not "); | ||
| 190 | } | 194 | } |
| 191 | 195 | ||
| 192 | ret = 0; | 196 | ret = 0; |
