]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
openssl: fix crash on missing cert password
authorJay Satiro <raysatiro@yahoo.com>
Mon, 24 Mar 2025 06:48:01 +0000 (02:48 -0400)
committerJay Satiro <raysatiro@yahoo.com>
Mon, 24 Mar 2025 22:22:53 +0000 (18:22 -0400)
- Return 0 for password length if OpenSSL is expecting a certificate
  password but the user did not provide one.

Prior to this change libcurl would crash if OpenSSL called the certificate
password callback in libcurl but no password was provided (NULL).

Reported-by: Roman Zharkov
Fixes https://github.com/curl/curl/issues/16806
Closes https://github.com/curl/curl/pull/16807

lib/vtls/openssl.c

index 1beda3133a64087b06738fb267a58c0ad1c131ce..4d5e1be29e57933510638e4bca5056234171a5ee 100644 (file)
@@ -931,14 +931,14 @@ static char *ossl_strerror(unsigned long error, char *buf, size_t size)
 }
 
 static int passwd_callback(char *buf, int num, int encrypting,
-                           void *global_passwd)
+                           void *password)
 {
   DEBUGASSERT(0 == encrypting);
 
-  if(!encrypting && num >= 0) {
-    int klen = curlx_uztosi(strlen((char *)global_passwd));
+  if(!encrypting && num >= 0 && password) {
+    int klen = curlx_uztosi(strlen((char *)password));
     if(num > klen) {
-      memcpy(buf, global_passwd, klen + 1);
+      memcpy(buf, password, klen + 1);
       return klen;
     }
   }