Bug 794510: Part 5 - use plarena.h type definitions; r=ehsan
authorIsaac Aggrey <isaac.aggrey@gmail.com>
Thu, 11 Oct 2012 01:39:28 -0500
changeset 110685 396742c90b0a00d4ffeeeb728c9dd0808a608c7a
parent 110684 01e26f56f07862129f9ec10ac1027b274bc4a8e2
child 110686 df7e936ddfd3d3af7b36cb43bb0447dc232e1c24
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersehsan
bugs794510
milestone19.0a1
Bug 794510: Part 5 - use plarena.h type definitions; r=ehsan
media/mtransport/dtlsidentity.cpp
security/manager/ssl/src/SSLServerCertVerification.cpp
security/manager/ssl/src/TransportSecurityInfo.cpp
security/manager/ssl/src/nsCRLManager.cpp
security/manager/ssl/src/nsCertTree.cpp
security/manager/ssl/src/nsDataSignatureVerifier.cpp
security/manager/ssl/src/nsKeygenHandler.cpp
security/manager/ssl/src/nsNSSCertHelper.cpp
security/manager/ssl/src/nsNSSCertificateDB.cpp
security/manager/ssl/src/nsNSSCertificateDB.h
security/manager/ssl/src/nsNSSIOLayer.cpp
--- a/media/mtransport/dtlsidentity.cpp
+++ b/media/mtransport/dtlsidentity.cpp
@@ -111,17 +111,17 @@ TemporaryRef<DtlsIdentity> DtlsIdentity:
   }
 
   ScopedCERTCertificate certificate(
       CERT_CreateCertificate(serial, subject_name, validity, certreq));
   if (!certificate) {
     return nullptr;
   }
 
-  PRArenaPool *arena = certificate->arena;
+  PLArenaPool *arena = certificate->arena;
 
   rv = SECOID_SetAlgorithmID(arena, &certificate->signature,
                              SEC_OID_PKCS1_SHA1_WITH_RSA_ENCRYPTION, 0);
   if (rv != SECSuccess)
     return nullptr;
 
   // Set version to X509v3.
   *(certificate->version.data) = SEC_CERTIFICATE_VERSION_3;
--- a/security/manager/ssl/src/SSLServerCertVerification.cpp
+++ b/security/manager/ssl/src/SSLServerCertVerification.cpp
@@ -122,17 +122,17 @@ extern PRLogModuleInfo* gPIPNSSLog;
 
 namespace mozilla { namespace psm {
 
 namespace {
 
 NS_DEFINE_CID(kNSSComponentCID, NS_NSSCOMPONENT_CID);
 
 NSSCleanupAutoPtrClass(CERTCertificate, CERT_DestroyCertificate)
-NSSCleanupAutoPtrClass_WithParam(PRArenaPool, PORT_FreeArena, FalseParam, false)
+NSSCleanupAutoPtrClass_WithParam(PLArenaPool, PORT_FreeArena, FalseParam, false)
 
 // do not use a nsCOMPtr to avoid static initializer/destructor
 nsIThreadPool * gCertVerificationThreadPool = nullptr;
 } // unnamed namespace
 
 // Called when the socket transport thread starts, to initialize the SSL cert
 // verification thread pool. By tying the thread pool startup/shutdown directly
 // to the STS thread's lifetime, we ensure that they are *always* available for
@@ -448,18 +448,18 @@ CreateCertErrorRunnable(PRErrorCode defa
   nsRefPtr<nsCERTValInParamWrapper> survivingParams;
   nsrv = inss->GetDefaultCERTValInParam(survivingParams);
   if (NS_FAILED(nsrv)) {
     NS_ERROR("GetDefaultCERTValInParam failed");
     PR_SetError(defaultErrorCodeToReport, 0);
     return nullptr;
   }
   
-  PRArenaPool *log_arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
-  PRArenaPoolCleanerFalseParam log_arena_cleaner(log_arena);
+  PLArenaPool *log_arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
+  PLArenaPoolCleanerFalseParam log_arena_cleaner(log_arena);
   if (!log_arena) {
     NS_ERROR("PORT_NewArena failed");
     return nullptr; // PORT_NewArena set error code
   }
 
   CERTVerifyLog *verify_log = PORT_ArenaZNew(log_arena, CERTVerifyLog);
   if (!verify_log) {
     NS_ERROR("PORT_ArenaZNew failed");
--- a/security/manager/ssl/src/TransportSecurityInfo.cpp
+++ b/security/manager/ssl/src/TransportSecurityInfo.cpp
@@ -736,17 +736,17 @@ static bool
 GetSubjectAltNames(CERTCertificate *nssCert,
                    nsINSSComponent *component,
                    nsString &allNames,
                    uint32_t &nameCount)
 {
   allNames.Truncate();
   nameCount = 0;
 
-  PRArenaPool *san_arena = nullptr;
+  PLArenaPool *san_arena = nullptr;
   SECItem altNameExtension = {siBuffer, NULL, 0 };
   CERTGeneralName *sanNameList = nullptr;
 
   SECStatus rv = CERT_FindCertExtension(nssCert, SEC_OID_X509_SUBJECT_ALT_NAME,
                                         &altNameExtension);
   if (rv != SECSuccess)
     return false;
 
--- a/security/manager/ssl/src/nsCRLManager.cpp
+++ b/security/manager/ssl/src/nsCRLManager.cpp
@@ -50,17 +50,17 @@ nsCRLManager::ImportCrl (uint8_t *aData,
 {
   if (!NS_IsMainThread()) {
     NS_ERROR("nsCRLManager::ImportCrl called off the main thread");
     return NS_ERROR_NOT_SAME_THREAD;
   }
   
   nsNSSShutDownPreventionLock locker;
   nsresult rv;
-  PRArenaPool *arena = NULL;
+  PLArenaPool *arena = NULL;
   CERTCertificate *caCert;
   SECItem derName = { siBuffer, NULL, 0 };
   SECItem derCrl;
   CERTSignedData sd;
   SECStatus sec_rv;
   CERTSignedCrl *crl;
   nsAutoCString url;
   nsCOMPtr<nsICRLInfo> crlData;
--- a/security/manager/ssl/src/nsCertTree.cpp
+++ b/security/manager/ssl/src/nsCertTree.cpp
@@ -1,12 +1,13 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "NSPRFormatTime.h" // must include before any headers that include prtime.h
 #include "nsNSSComponent.h" // for PIPNSS string bundle calls.
 #include "nsCertTree.h"
 #include "nsITreeColumns.h"
 #include "nsIX509Cert.h"
 #include "nsIX509CertValidity.h"
 #include "nsIX509CertDB.h"
 #include "nsXPIDLString.h"
 #include "nsReadableUtils.h"
--- a/security/manager/ssl/src/nsDataSignatureVerifier.cpp
+++ b/security/manager/ssl/src/nsDataSignatureVerifier.cpp
@@ -30,17 +30,17 @@ const SEC_ASN1Template CERT_SignatureDat
 
 NS_IMETHODIMP
 nsDataSignatureVerifier::VerifyData(const nsACString & aData,
                                     const nsACString & aSignature,
                                     const nsACString & aPublicKey,
                                     bool *_retval)
 {
     // Allocate an arena to handle the majority of the allocations
-    PRArenaPool *arena;
+    PLArenaPool *arena;
     arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
     if (!arena)
         return NS_ERROR_OUT_OF_MEMORY;
 
     // Base 64 decode the key
     SECItem keyItem;
     PORT_Memset(&keyItem, 0, sizeof(SECItem));
     if (!NSSBase64_DecodeBuffer(arena, &keyItem,
--- a/security/manager/ssl/src/nsKeygenHandler.cpp
+++ b/security/manager/ssl/src/nsKeygenHandler.cpp
@@ -76,17 +76,17 @@ const SEC_ASN1Template SECKEY_PQGParamsT
 static NS_DEFINE_IID(kIDOMHTMLSelectElementIID, NS_IDOMHTMLSELECTELEMENT_IID);
 static NS_DEFINE_CID(kNSSComponentCID, NS_NSSCOMPONENT_CID);
 
 static PQGParams *
 decode_pqg_params(char *aStr)
 {
     unsigned char *buf = nullptr;
     unsigned int len;
-    PRArenaPool *arena = nullptr;
+    PLArenaPool *arena = nullptr;
     PQGParams *params = nullptr;
     SECStatus status;
 
     arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
     if (!arena)
         return nullptr;
 
     params = static_cast<PQGParams*>(PORT_ArenaZAlloc(arena, sizeof(PQGParams)));
@@ -480,17 +480,17 @@ nsKeygenFormProcessor::GetPublicKey(nsAS
     PK11SlotInfo *slot = nullptr;
     PK11RSAGenParams rsaParams;
     SECOidTag algTag;
     int keysize = 0;
     void *params;
     SECKEYPrivateKey *privateKey = nullptr;
     SECKEYPublicKey *publicKey = nullptr;
     CERTSubjectPublicKeyInfo *spkInfo = nullptr;
-    PRArenaPool *arena = nullptr;
+    PLArenaPool *arena = nullptr;
     SECStatus sec_rv = SECFailure;
     SECItem spkiItem;
     SECItem pkacItem;
     SECItem signedItem;
     CERTPublicKeyAndChallenge pkac;
     pkac.challenge.data = nullptr;
     nsIGeneratingKeypairInfoDialogs * dialogs;
     nsKeygenThread *KeygenRunnable = 0;
--- a/security/manager/ssl/src/nsNSSCertHelper.cpp
+++ b/security/manager/ssl/src/nsNSSCertHelper.cpp
@@ -985,17 +985,17 @@ ProcessIA5String(SECItem  *extData,
     return NS_ERROR_FAILURE;
   local.AssignASCII((char*)item.data, item.len);
   nsMemory::Free(item.data);
   text.Append(local);
   return NS_OK;
 }
 
 static nsresult
-AppendBMPtoUTF16(PRArenaPool *arena,
+AppendBMPtoUTF16(PLArenaPool *arena,
 		 unsigned char* data, unsigned int len,
 		 nsAString& text)
 {
   unsigned int   utf8ValLen;
   unsigned char *utf8Val;
 
   if (len % 2 != 0)
     return NS_ERROR_FAILURE;
@@ -1012,33 +1012,33 @@ AppendBMPtoUTF16(PRArenaPool *arena,
 }
 
 static nsresult
 ProcessBMPString(SECItem  *extData, 
 		 nsAString &text,
 		 nsINSSComponent *nssComponent)
 {
   SECItem item;
-  PRArenaPool *arena;
+  PLArenaPool *arena;
   nsresult rv = NS_ERROR_FAILURE;
   
   arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
   if (!arena)
     return NS_ERROR_FAILURE;
 
   if (SECSuccess == SEC_ASN1DecodeItem(arena, &item, 
 				       SEC_ASN1_GET(SEC_BMPStringTemplate),
 				       extData))
     rv = AppendBMPtoUTF16(arena, item.data, item.len, text);
   PORT_FreeArena(arena, false);
   return rv;
 }
 
 static nsresult
-ProcessGeneralName(PRArenaPool *arena,
+ProcessGeneralName(PLArenaPool *arena,
 		   CERTGeneralName *current,
 		   nsAString &text,
 		   nsINSSComponent *nssComponent)
 {
   NS_ENSURE_ARG_POINTER(current);
 
   nsAutoString key;
   nsXPIDLString value;
@@ -1151,17 +1151,17 @@ ProcessGeneralName(PRArenaPool *arena,
   text.Append(NS_LITERAL_STRING(": "));
   text.Append(value);
   text.Append(NS_LITERAL_STRING(SEPARATOR));
  finish:
     return rv;
 }
 
 static nsresult
-ProcessGeneralNames(PRArenaPool *arena,
+ProcessGeneralNames(PLArenaPool *arena,
 		    CERTGeneralName *nameList,
 		    nsAString &text,
 		    nsINSSComponent *nssComponent)
 {
   CERTGeneralName *current = nameList;
   nsresult rv;
 
   do {
@@ -1174,17 +1174,17 @@ ProcessGeneralNames(PRArenaPool *arena,
 }
 
 static nsresult
 ProcessAltName(SECItem  *extData, 
 	       nsAString &text,
 	       nsINSSComponent *nssComponent)
 {
   nsresult rv = NS_OK;
-  PRArenaPool *arena;
+  PLArenaPool *arena;
   CERTGeneralName *nameList;
 
   arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
   if (!arena)
     return NS_ERROR_FAILURE;
 
   nameList = CERT_DecodeAltNameExtension(arena, extData);
   if (!nameList)
@@ -1197,17 +1197,17 @@ ProcessAltName(SECItem  *extData,
   return rv;
 }
 
 static nsresult
 ProcessSubjectKeyId(SECItem  *extData, 
 		    nsAString &text,
 		    nsINSSComponent *nssComponent)
 {
-  PRArenaPool *arena;
+  PLArenaPool *arena;
   nsresult rv = NS_OK;
   SECItem decoded;
   nsAutoString local;
 
   arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
   if (!arena)
     return NS_ERROR_FAILURE;
 
@@ -1229,17 +1229,17 @@ ProcessSubjectKeyId(SECItem  *extData,
 }
 
 static nsresult
 ProcessAuthKeyId(SECItem  *extData, 
 		 nsAString &text,
 		 nsINSSComponent *nssComponent)
 {
   CERTAuthKeyID *ret;
-  PRArenaPool *arena;
+  PLArenaPool *arena;
   nsresult rv = NS_OK;
   nsAutoString local;
 
   arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
   if (!arena)
     return NS_ERROR_OUT_OF_MEMORY;
 
   ret = CERT_DecodeAuthKeyID (arena, extData);
@@ -1279,17 +1279,17 @@ ProcessAuthKeyId(SECItem  *extData,
 
 static nsresult
 ProcessUserNotice(SECItem *der_notice,
 		  nsAString &text,
 		  nsINSSComponent *nssComponent)
 {
   CERTUserNotice *notice = NULL;
   SECItem **itemList;
-  PRArenaPool *arena;
+  PLArenaPool *arena;
 
   arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
   if (!arena)
     return NS_ERROR_FAILURE;
 
   notice = CERT_DecodeUserNotice(der_notice);
   if (notice == NULL) {
     ProcessRawBytes(nssComponent, der_notice, text);
@@ -1444,17 +1444,17 @@ ProcessCertificatePolicies(SECItem  *ext
 
 static nsresult
 ProcessCrlDistPoints(SECItem  *extData, 
 		     nsAString &text,
 		     nsINSSComponent *nssComponent)
 {
   CERTCrlDistributionPoints *crldp;
   CRLDistributionPoint **points, *point;
-  PRArenaPool *arena;
+  PLArenaPool *arena;
   nsresult rv = NS_OK;
   nsAutoString local;
   int reasons, comma;
 
   arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
   if (!arena)
     return NS_ERROR_FAILURE;
 
@@ -1537,17 +1537,17 @@ ProcessCrlDistPoints(SECItem  *extData,
 }
 
 static nsresult
 ProcessAuthInfoAccess(SECItem  *extData, 
 		      nsAString &text,
 		      nsINSSComponent *nssComponent)
 {
   CERTAuthInfoAccess **aia, *desc;
-  PRArenaPool *arena;
+  PLArenaPool *arena;
   nsresult rv = NS_OK;
   nsAutoString local;
 
   arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
   if (!arena)
     return NS_ERROR_FAILURE;
 
   aia = CERT_DecodeAuthInfoAccessExtension(arena, extData);
--- a/security/manager/ssl/src/nsNSSCertificateDB.cpp
+++ b/security/manager/ssl/src/nsNSSCertificateDB.cpp
@@ -214,17 +214,17 @@ collect_certs(void *arg, SECItem **certs
     cert++;
     certs++;
   }
 
   return (SECSuccess);
 }
 
 CERTDERCerts*
-nsNSSCertificateDB::getCertsFromPackage(PRArenaPool *arena, uint8_t *data, 
+nsNSSCertificateDB::getCertsFromPackage(PLArenaPool *arena, uint8_t *data, 
                                         uint32_t length)
 {
   nsNSSShutDownPreventionLock locker;
   CERTDERCerts *collectArgs = 
                (CERTDERCerts *)PORT_ArenaZAlloc(arena, sizeof(CERTDERCerts));
   if ( collectArgs == nullptr ) 
     return nullptr;
 
@@ -433,17 +433,17 @@ NS_IMETHODIMP
 nsNSSCertificateDB::ImportCertificates(uint8_t * data, uint32_t length, 
                                        uint32_t type, 
                                        nsIInterfaceRequestor *ctx)
 
 {
   nsNSSShutDownPreventionLock locker;
   nsresult nsrv;
 
-  PRArenaPool *arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
+  PLArenaPool *arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
   if (!arena)
     return NS_ERROR_OUT_OF_MEMORY;
 
   CERTDERCerts *certCollection = getCertsFromPackage(arena, data, length);
   if (!certCollection) {
     PORT_FreeArena(arena, false);
     return NS_ERROR_FAILURE;
   }
@@ -508,17 +508,17 @@ nsNSSCertificateDB::ImportEmailCertifica
   nsCOMPtr<nsINSSComponent> inss = do_GetService(kNSSComponentCID, &nsrv);
   if (!inss)
     return nsrv;
   nsRefPtr<nsCERTValInParamWrapper> survivingParams;
   nsrv = inss->GetDefaultCERTValInParam(survivingParams);
   if (NS_FAILED(nsrv))
     return nsrv;
  
-  PRArenaPool *arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
+  PLArenaPool *arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
   if (!arena)
     return NS_ERROR_OUT_OF_MEMORY;
 
   CERTDERCerts *certCollection = getCertsFromPackage(arena, data, length);
   if (!certCollection) {
     PORT_FreeArena(arena, false);
     return NS_ERROR_FAILURE;
   }
@@ -652,17 +652,17 @@ nsNSSCertificateDB::ImportServerCertific
   nsresult nsrv = NS_OK;
   CERTCertificate * cert;
   SECItem **rawCerts = nullptr;
   int numcerts;
   int i;
   nsNSSCertTrust trust;
   char *serverNickname = nullptr;
  
-  PRArenaPool *arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
+  PLArenaPool *arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
   if (!arena)
     return NS_ERROR_OUT_OF_MEMORY;
 
   CERTDERCerts *certCollection = getCertsFromPackage(arena, data, length);
   if (!certCollection) {
     PORT_FreeArena(arena, false);
     return NS_ERROR_FAILURE;
   }
@@ -887,17 +887,17 @@ nsNSSCertificateDB::ImportUserCertificat
   
   nsNSSShutDownPreventionLock locker;
   PK11SlotInfo *slot;
   nsAutoCString nickname;
   nsresult rv = NS_ERROR_FAILURE;
   int numCACerts;
   SECItem *CACerts;
   CERTDERCerts * collectArgs;
-  PRArenaPool *arena;
+  PLArenaPool *arena;
   CERTCertificate * cert=NULL;
 
   arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
   if ( arena == NULL ) {
     goto loser;
   }
 
   collectArgs = getCertsFromPackage(arena, data, length);
--- a/security/manager/ssl/src/nsNSSCertificateDB.h
+++ b/security/manager/ssl/src/nsNSSCertificateDB.h
@@ -38,17 +38,17 @@ private:
   static void DisplayCertificateAlert(nsIInterfaceRequestor *ctx, 
                                       const char *stringID, nsIX509Cert *certToShow);
 
   void getCertNames(CERTCertList *certList,
                     uint32_t      type, 
                     uint32_t     *_count,
                     PRUnichar  ***_certNameList);
 
-  CERTDERCerts *getCertsFromPackage(PRArenaPool *arena, uint8_t *data, 
+  CERTDERCerts *getCertsFromPackage(PLArenaPool *arena, uint8_t *data, 
                                     uint32_t length);
   nsresult handleCACertDownload(nsIArray *x509Certs, 
                                 nsIInterfaceRequestor *ctx);
 };
 
 #define NS_X509CERTDB_CID { /* fb0bbc5c-452e-4783-b32c-80124693d871 */ \
     0xfb0bbc5c,                                                        \
     0x452e,                                                            \
--- a/security/manager/ssl/src/nsNSSIOLayer.cpp
+++ b/security/manager/ssl/src/nsNSSIOLayer.cpp
@@ -1345,17 +1345,17 @@ nsSSLIOLayerNewSocket(int32_t family,
  * Arguments and return values
  * - arena: arena to allocate strings on
  * - caNameStrings: filled with CA names strings on return
  * - caNames: CERTDistNames to extract strings from
  * - return: SECSuccess if successful; error code otherwise
  *
  * Note: copied in its entirety from Nova code
  */
-SECStatus nsConvertCANamesToStrings(PRArenaPool* arena, char** caNameStrings,
+SECStatus nsConvertCANamesToStrings(PLArenaPool* arena, char** caNameStrings,
                                       CERTDistNames* caNames)
 {
     SECItem* dername;
     SECStatus rv;
     int headerlen;
     uint32_t contentlen;
     SECItem newitem;
     int n;
@@ -1581,17 +1581,17 @@ static char* _str_to_lower(char* string)
  * the port) does not satisfy the restriction
  */
 static bool CERT_MatchesScopeOfUse(CERTCertificate* cert, char* hostname,
                                      char* hostIP, int port)
 {
     bool rv = true; /* whether the cert can be presented */
     SECStatus srv;
     SECItem extData;
-    PRArenaPool* arena = NULL;
+    PLArenaPool* arena = NULL;
     CERTCertificateScopeEntry** entries = NULL;
     /* arrays of decoded scope entries */
     int numEntries = 0;
     int i;
     char* hostLower = NULL;
     uint32_t hostIPAddr = 0;
 
     PR_ASSERT((cert != NULL) && (hostname != NULL) && (hostIP != NULL));
@@ -1894,17 +1894,17 @@ SECStatus nsNSS_SSLGetClientAuthData(voi
     info->SetSentClientCert();
   }
 
   return runnable->mRV;
 }
 
 void ClientAuthDataRunnable::RunOnTargetThread()
 {
-  PRArenaPool* arena = NULL;
+  PLArenaPool* arena = NULL;
   char** caNameStrings;
   CERTCertificate* cert = NULL;
   SECKEYPrivateKey* privKey = NULL;
   CERTCertList* certList = NULL;
   CERTCertListNode* node;
   CERTCertNicknames* nicknames = NULL;
   char* extracted = NULL;
   int keyError = 0; /* used for private key retrieval error */