← Commit list

a6c940a752

x2018
x2018
2025-11-17
SUCCESS Duration: 151s

Subject

schannel_verify: fix a memory leak of cert_context

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

lib/vtls/schannel_verify.c+16 -1
@@ -166,6 +166,7 @@ static CURLcode add_certs_data_to_store(HCERTSTORE trust_store,
cert_blob.pbData = (BYTE *)CURL_UNCONST(begin_cert_ptr);
cert_blob.cbData = cert_size;
+ /* Caution: CryptQueryObject() is deprecated */
if(!CryptQueryObject(CERT_QUERY_OBJECT_BLOB,
&cert_blob,
CERT_QUERY_CONTENT_FLAG_CERT,
@@ -204,7 +205,6 @@ static CURLcode add_certs_data_to_store(HCERTSTORE trust_store,
cert_context,
CERT_STORE_ADD_ALWAYS,
NULL);
- CertFreeCertificateContext(cert_context);
if(!add_cert_result) {
char buffer[WINAPI_ERROR_LEN];
failf(data,
@@ -220,6 +220,21 @@ static CURLcode add_certs_data_to_store(HCERTSTORE trust_store,
num_certs++;
}
}
+
+ switch(actual_content_type) {
+ case CERT_QUERY_CONTENT_CERT:
+ case CERT_QUERY_CONTENT_SERIALIZED_CERT:
+ CertFreeCertificateContext(cert_context);
+ break;
+ case CERT_QUERY_CONTENT_CRL:
+ case CERT_QUERY_CONTENT_SERIALIZED_CRL:
+ CertFreeCRLContext((PCCRL_CONTEXT)cert_context);
+ break;
+ case CERT_QUERY_CONTENT_CTL:
+ case CERT_QUERY_CONTENT_SERIALIZED_CTL:
+ CertFreeCTLContext((PCCTL_CONTEXT)cert_context);
+ break;
+ }
}
}
}