apps: properly initialise arguments to EVP_PKEY_get_bn_param()
authorPauli <pauli@openssl.org>
Thu, 24 Jun 2021 23:28:26 +0000 (09:28 +1000)
committerPauli <pauli@openssl.org>
Sat, 26 Jun 2021 01:32:38 +0000 (11:32 +1000)
This avoids use of uninitialised memory.

Follow on to #15900

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15908)

apps/req.c
apps/x509.c

index 9fbe4e250f4416d5d9096b5e5d67322599b5bd92..d0c620438bc912804bb8ad0ba5688a61d2e27e32 100644 (file)
@@ -994,7 +994,7 @@ int req_main(int argc, char **argv)
         }
         fprintf(stdout, "Modulus=");
         if (EVP_PKEY_is_a(tpubkey, "RSA")) {
-            BIGNUM *n;
+            BIGNUM *n = NULL;
 
             /* Every RSA key has an 'n' */
             EVP_PKEY_get_bn_param(pkey, "n", &n);
index 558351ba304c875797a7fc048fe803bef1edcb7b..b68530fb2251b14e78a1985ac4d12c4c2127b2cf 100644 (file)
@@ -950,7 +950,7 @@ int x509_main(int argc, char **argv)
                 BN_print(out, n);
                 BN_free(n);
             } else if (EVP_PKEY_is_a(pkey, "DSA")) {
-                BIGNUM *dsapub;
+                BIGNUM *dsapub = NULL;
 
                 /* Every DSA key has a 'pub' */
                 EVP_PKEY_get_bn_param(pkey, "pub", &dsapub);