Bug 1010634, Part 3: Fix more warnings in CertVerifier, r=cviecco

--HG--
extra : rebase_source : 21e79fbc472aeccec7df213e0cd8d99bebfbff75
This commit is contained in:
Brian Smith 2014-05-29 20:17:53 -07:00
parent 90eef2f5d9
commit 78cf7bf1aa
2 changed files with 30 additions and 6 deletions

View File

@ -6,6 +6,8 @@
#include "OCSPRequestor.h"
#include <limits>
#include "mozilla/Base64.h"
#include "nsIURLParser.h"
#include "nsNSSCallbacks.h"
@ -69,6 +71,16 @@ DoOCSPRequest(PLArenaPool* arena, const char* url,
const SECItem* encodedRequest, PRIntervalTime timeout,
bool useGET)
{
if (!arena || !url || !encodedRequest || !encodedRequest->data) {
PR_SetError(SEC_ERROR_INVALID_ARGS, 0);
return nullptr;
}
uint32_t urlLen = PL_strlen(url);
if (urlLen > static_cast<uint32_t>(std::numeric_limits<int32_t>::max())) {
PR_SetError(SEC_ERROR_INVALID_ARGS, 0);
return nullptr;
}
nsCOMPtr<nsIURLParser> urlParser = do_GetService(NS_STDURLPARSER_CONTRACTID);
if (!urlParser) {
PR_SetError(SEC_ERROR_LIBRARY_FAILURE, 0);
@ -81,7 +93,7 @@ DoOCSPRequest(PLArenaPool* arena, const char* url,
int32_t authorityLen;
uint32_t pathPos;
int32_t pathLen;
nsresult rv = urlParser->ParseURL(url, PL_strlen(url),
nsresult rv = urlParser->ParseURL(url, static_cast<int32_t>(urlLen),
&schemePos, &schemeLen,
&authorityPos, &authorityLen,
&pathPos, &pathLen);
@ -93,7 +105,8 @@ DoOCSPRequest(PLArenaPool* arena, const char* url,
PR_SetError(SEC_ERROR_CERT_BAD_ACCESS_LOCATION, 0);
return nullptr;
}
nsAutoCString scheme(url + schemePos, schemeLen);
nsAutoCString scheme(url + schemePos,
static_cast<nsAutoCString::size_type>(schemeLen));
if (!scheme.LowerCaseEqualsLiteral("http")) {
// We dont support https:// to avoid loops see Bug 92923
PR_SetError(SEC_ERROR_CERT_BAD_ACCESS_LOCATION, 0);
@ -118,11 +131,17 @@ DoOCSPRequest(PLArenaPool* arena, const char* url,
}
if (port == -1) {
port = 80;
} else if (port < 0 || port > 0xffff) {
PR_SetError(SEC_ERROR_CERT_BAD_ACCESS_LOCATION, 0);
return nullptr;
}
nsAutoCString hostname(url + authorityPos + hostnamePos, hostnameLen);
nsAutoCString
hostname(url + authorityPos + hostnamePos,
static_cast<nsACString_internal::size_type>(hostnameLen));
SEC_HTTP_SERVER_SESSION serverSessionPtr = nullptr;
if (nsNSSHttpInterface::createSessionFcn(hostname.BeginReading(), port,
if (nsNSSHttpInterface::createSessionFcn(hostname.BeginReading(),
static_cast<uint16_t>(port),
&serverSessionPtr) != SECSuccess) {
PR_SetError(SEC_ERROR_NO_MEMORY, 0);
return nullptr;
@ -132,7 +151,7 @@ DoOCSPRequest(PLArenaPool* arena, const char* url,
nsAutoCString path;
if (pathLen > 0) {
path.Assign(url + pathPos, pathLen);
path.Assign(url + pathPos, static_cast<nsAutoCString::size_type>(pathLen));
} else {
path.Assign("/");
}
@ -151,7 +170,7 @@ DoOCSPRequest(PLArenaPool* arena, const char* url,
}
}
SEC_HTTP_REQUEST_SESSION requestSessionPtr = nullptr;
SEC_HTTP_REQUEST_SESSION requestSessionPtr;
if (nsNSSHttpInterface::createFcn(serverSession.get(), "http",
path.get(), method.get(),
timeout, &requestSessionPtr)
@ -159,6 +178,7 @@ DoOCSPRequest(PLArenaPool* arena, const char* url,
PR_SetError(SEC_ERROR_NO_MEMORY, 0);
return nullptr;
}
ScopedHTTPRequestSession requestSession(
reinterpret_cast<nsNSSHttpRequestSession*>(requestSessionPtr));

View File

@ -33,6 +33,10 @@ private:
// For XPCOM implementations that are not a base class for some other
// class, it is good practice to make the destructor non-virtual and
// private. Then the only way to delete the object is via Release.
#ifdef _MSC_VER
// C4265: Class has virtual members but destructor is not virtual
__pragma(warning(disable:4265))
#endif
~nsHTTPListener();
public: