Bug 507379 - hostname from SSL_RevealURL is null checked too late [@ nsDependentCString - nsNSSBadCertHandler]; r=kaie

This commit is contained in:
timeless 2009-08-25 15:22:28 +02:00
parent 1766cc0dda
commit 672d60d0bf

View File

@ -3197,8 +3197,11 @@ nsNSSBadCertHandler(void *arg, PRFileDesc *sslSocket)
PRErrorCode errorCodeTrust = SECSuccess; PRErrorCode errorCodeTrust = SECSuccess;
PRErrorCode errorCodeMismatch = SECSuccess; PRErrorCode errorCodeMismatch = SECSuccess;
PRErrorCode errorCodeExpired = SECSuccess; PRErrorCode errorCodeExpired = SECSuccess;
char *hostname = SSL_RevealURL(sslSocket); char *hostname = SSL_RevealURL(sslSocket);
if (!hostname)
return cancel_and_failure(infoObject);
charCleaner hostnameCleaner(hostname); charCleaner hostnameCleaner(hostname);
nsDependentCString hostString(hostname); nsDependentCString hostString(hostname);
@ -3212,7 +3215,7 @@ nsNSSBadCertHandler(void *arg, PRFileDesc *sslSocket)
NS_ConvertUTF8toUTF16 hostWithPortStringUTF16(hostWithPortString); NS_ConvertUTF8toUTF16 hostWithPortStringUTF16(hostWithPortString);
// Check the name field against the desired hostname. // Check the name field against the desired hostname.
if (hostname && hostname[0] && if (hostname[0] &&
CERT_VerifyCertName(peerCert, hostname) != SECSuccess) { CERT_VerifyCertName(peerCert, hostname) != SECSuccess) {
collected_errors |= nsICertOverrideService::ERROR_MISMATCH; collected_errors |= nsICertOverrideService::ERROR_MISMATCH;
errorCodeMismatch = SSL_ERROR_BAD_CERT_DOMAIN; errorCodeMismatch = SSL_ERROR_BAD_CERT_DOMAIN;