aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJakub Zelenka <[email protected]>2026-08-29 13:52:08 +0200
committerTomas Mraz <[email protected]>2026-09-07 16:15:20 +0200
commitd6d126cc6fd623ce7efe85a1de2e0bf60230aaab (patch)
tree78ecd25f191b313563170b9c10179fe79663aabf /apps
parenttest framework: add app_fails and slurp_file to OpenSSL::Test (diff)
downloadopenssl-d6d126cc6fd623ce7efe85a1de2e0bf60230aaab.tar.gz
openssl-d6d126cc6fd623ce7efe85a1de2e0bf60230aaab.zip
apps: print an error for a non-positive genrsa bits argument
Previously a negative or zero numbits argument made genrsa exit with a failure status without printing any error message. Assisted-by: Claude:claude-fable-5 Reviewed-by: Dmitry Belyavskiy <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> Merge-date: Mon Sep 7 14:15:50 2026 Merged-from: https://github.com/openssl/openssl/pull/32592
Diffstat (limited to 'apps')
-rw-r--r--apps/genrsa.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/apps/genrsa.c b/apps/genrsa.c
index 9187fa9ce0f..6150f59a871 100644
--- a/apps/genrsa.c
+++ b/apps/genrsa.c
@@ -153,8 +153,12 @@ int genrsa_main(int argc, char **argv)
argv = opt_rest();
if (argc == 1) {
- if (!opt_int(argv[0], &num) || num <= 0)
+ if (!opt_int(argv[0], &num))
goto end;
+ if (num <= 0) {
+ BIO_printf(bio_err, "%s: Invalid number of bits: %d\n", prog, num);
+ goto end;
+ }
if (num > OPENSSL_RSA_MAX_MODULUS_BITS)
BIO_printf(bio_err,
"Warning: It is not recommended to use more than %d bit for RSA keys.\n"