Commit d6d126cc6f for openssl.org

commit d6d126cc6fd623ce7efe85a1de2e0bf60230aaab
Author: Jakub Zelenka <jakub.zelenka@openssl.foundation>
Date:   Sat Aug 29 13:52:08 2026 +0200

    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 <beldmit@gmail.com>
    Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
    Merge-date: Mon Sep  7 14:15:50 2026
    Merged-from: https://github.com/openssl/openssl/pull/32592

diff --git a/apps/genrsa.c b/apps/genrsa.c
index 9187fa9ce0..6150f59a87 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"