Commit 3f06a096 authored by Wei Xie's avatar Wei Xie Committed by Alexandre Julliard

wininet/tests: Check null pointer in InternetGetSecurityInfoByURLW.

parent 946b4ad2
......@@ -4462,6 +4462,11 @@ BOOL WINAPI InternetGetSecurityInfoByURLW(LPCWSTR lpszURL, PCCERT_CHAIN_CONTEXT
TRACE("(%s %p %p)\n", debugstr_w(lpszURL), ppCertChain, pdwSecureFlags);
if (!ppCertChain && !pdwSecureFlags) {
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
url.dwHostNameLength = 1;
res = InternetCrackUrlW(lpszURL, 0, 0, &url);
if(!res || url.nScheme != INTERNET_SCHEME_HTTPS) {
......@@ -4476,15 +4481,11 @@ BOOL WINAPI InternetGetSecurityInfoByURLW(LPCWSTR lpszURL, PCCERT_CHAIN_CONTEXT
}
if(server->cert_chain) {
const CERT_CHAIN_CONTEXT *chain_dup;
chain_dup = CertDuplicateCertificateChain(server->cert_chain);
if(chain_dup) {
*ppCertChain = chain_dup;
if(pdwSecureFlags)
*pdwSecureFlags = server->security_flags & _SECURITY_ERROR_FLAGS_MASK;
}else {
if(ppCertChain && !(*ppCertChain = CertDuplicateCertificateChain(server->cert_chain)))
res = FALSE;
}
}else {
SetLastError(ERROR_INTERNET_ITEM_NOT_FOUND);
res = FALSE;
......
......@@ -5593,6 +5593,18 @@ static void _test_security_info(unsigned line, const char *urlc, DWORD error, DW
ok_(__FILE__,line)(chain != NULL, "chain = NULL\n");
ok_(__FILE__,line)(flags == ex_flags, "flags = %x\n", flags);
CertFreeCertificateChain(chain);
SetLastError(0xdeadbeef);
res = pInternetGetSecurityInfoByURLA(url, NULL, NULL);
ok_(__FILE__,line)(!res && GetLastError() == ERROR_INVALID_PARAMETER,
"InternetGetSecurityInfoByURLA returned: %x(%u)\n", res, GetLastError());
res = pInternetGetSecurityInfoByURLA(url, &chain, NULL);
ok_(__FILE__,line)(res, "InternetGetSecurityInfoByURLA failed: %u\n", GetLastError());
CertFreeCertificateChain(chain);
res = pInternetGetSecurityInfoByURLA(url, NULL, &flags);
ok_(__FILE__,line)(res, "InternetGetSecurityInfoByURLA failed: %u\n", GetLastError());
}else {
ok_(__FILE__,line)(!res && GetLastError() == error,
"InternetGetSecurityInfoByURLA returned: %x(%u), expected %u\n", res, GetLastError(), error);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment