From bc6726797e8c81191770857276151f5b03b3a867 Mon Sep 17 00:00:00 2001 From: Wolfgang Germund Date: Fri, 28 Oct 2011 15:43:01 +0200 Subject: [PATCH] Bug 697061: better string handling in nsJAR.cpp. r=tglek --- modules/libjar/nsJAR.cpp | 11 +++++------ modules/libjar/nsJAR.h | 5 +---- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/modules/libjar/nsJAR.cpp b/modules/libjar/nsJAR.cpp index fdde46d7578..2e028ceb342 100644 --- a/modules/libjar/nsJAR.cpp +++ b/modules/libjar/nsJAR.cpp @@ -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(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"); diff --git a/modules/libjar/nsJAR.h b/modules/libjar/nsJAR.h index b03b282c545..8725574a4e0 100644 --- a/modules/libjar/nsJAR.h +++ b/modules/libjar/nsJAR.h @@ -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); }; /**