Bug 697061: better string handling in nsJAR.cpp. r=tglek

This commit is contained in:
Wolfgang Germund 2011-10-28 15:43:01 +02:00
parent 8c01a25338
commit e58ffede12
2 changed files with 6 additions and 10 deletions

View File

@ -400,11 +400,10 @@ nsJAR::GetCertificatePrincipal(const nsACString &aFilename, nsIPrincipal** aPrin
return NS_OK;
PRInt16 requestedStatus;
const char *filename = PromiseFlatCString(aFilename).get();
if (*filename)
if (!aFilename.IsEmpty())
{
//-- Find the item
nsCStringKey key(filename);
nsCStringKey key(aFilename);
nsJARManifestItem* manItem = static_cast<nsJARManifestItem*>(mManifestData.Get(&key));
if (!manItem)
return NS_OK;
@ -424,7 +423,7 @@ nsJAR::GetCertificatePrincipal(const nsACString &aFilename, nsIPrincipal** aPrin
requestedStatus = mGlobalStatus;
if (requestedStatus != JAR_VALID_MANIFEST)
ReportError(filename, requestedStatus);
ReportError(aFilename, requestedStatus);
else // Valid signature
{
*aPrincipal = mPrincipal;
@ -840,12 +839,12 @@ nsJAR::VerifyEntry(nsJARManifestItem* aManItem, const char* aEntryData,
return NS_OK;
}
void nsJAR::ReportError(const char* aFilename, PRInt16 errorCode)
void nsJAR::ReportError(const nsACString &aFilename, PRInt16 errorCode)
{
//-- Generate error message
nsAutoString message;
message.AssignLiteral("Signature Verification Error: the signature on ");
if (aFilename)
if (!aFilename.IsEmpty())
message.AppendWithConversion(aFilename);
else
message.AppendLiteral("this .jar archive");

View File

@ -146,7 +146,7 @@ class nsJAR : public nsIZipReader
bool mOpened;
nsresult ParseManifest();
void ReportError(const char* aFilename, PRInt16 errorCode);
void ReportError(const nsACString &aFilename, PRInt16 errorCode);
nsresult LoadEntry(const nsACString &aFilename, char** aBuf,
PRUint32* aBufLen = nsnull);
PRInt32 ReadLine(const char** src);
@ -156,9 +156,6 @@ class nsJAR : public nsIZipReader
nsresult CalculateDigest(const char* aInBuf, PRUint32 aInBufLen,
nsCString& digest);
//-- Debugging
void DumpMetadata(const char* aMessage);
};
/**