]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
openssl: avoid BN_num_bits() NULL pointer derefs
authorDaniel Stenberg <daniel@haxx.se>
Thu, 12 Oct 2023 14:00:38 +0000 (16:00 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 13 Oct 2023 09:00:18 +0000 (11:00 +0200)
Reported-by: icy17 on github
Fixes #12099
Closes #12100

lib/vtls/openssl.c

index 9f9c8d136a29bf29256f4bcdbdb19c1079d1c699..6be86f871445899086f33453080fcfc89c82283f 100644 (file)
@@ -538,9 +538,9 @@ CURLcode Curl_ossl_certchain(struct Curl_easy *data, SSL *ssl)
 #else
           RSA_get0_key(rsa, &n, &e, NULL);
 #endif /* HAVE_EVP_PKEY_GET_PARAMS */
-          BIO_printf(mem, "%d", BN_num_bits(n));
+          BIO_printf(mem, "%d", n ? BN_num_bits(n) : 0);
 #else
-          BIO_printf(mem, "%d", BN_num_bits(rsa->n));
+          BIO_printf(mem, "%d", rsa->n ? BN_num_bits(rsa->n) : 0);
 #endif /* HAVE_OPAQUE_RSA_DSA_DH */
           push_certinfo("RSA Public Key", i);
           print_pubkey_BN(rsa, n, i);