From 89fe295257f374647122f73776ddb34555c543f0 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Thu, 24 Jun 2021 17:47:30 +0200 Subject: [PATCH] Fix segfault in openssl x509 -modulus The command ``openssl x509 -noout -modulus -in cert.pem`` used to segfaults sometimes because an uninitialized variable was passed to ``BN_lebin2bn``. The bug triggered an assertion in bn_expand_internal(). Fixes: https://github.com/openssl/openssl/issues/15899 Signed-off-by: Christian Heimes Reviewed-by: Matt Caswell Reviewed-by: Dmitry Belyavskiy Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/15900) --- apps/x509.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/x509.c b/apps/x509.c index b68530fb225..e9a45e4d8f7 100644 --- a/apps/x509.c +++ b/apps/x509.c @@ -943,7 +943,7 @@ int x509_main(int argc, char **argv) } else if (i == modulus) { BIO_printf(out, "Modulus="); if (EVP_PKEY_is_a(pkey, "RSA")) { - BIGNUM *n; + BIGNUM *n = NULL; /* Every RSA key has an 'n' */ EVP_PKEY_get_bn_param(pkey, "n", &n); -- 2.47.2