Bug 1464616 - make sure arenas are the same, r=mt
authorFranziskus Kiefer <franziskuskiefer@gmail.com>
Wed, 06 Jun 2018 10:42:53 +0200
changeset 14399 db7f6facd8dfa0ec4f91612b62c563ecf3892063
parent 14398 26bfb61fde636ad3caeaee7708b9818a4423805d
child 14400 ca18ca4ba00d97ac9683d92d3a16d9832342ba75
push id3121
push userfranziskuskiefer@gmail.com
push dateFri, 08 Jun 2018 12:51:03 +0000
reviewersmt
bugs1464616
Bug 1464616 - make sure arenas are the same, r=mt Differential Revision: https://phabricator.services.mozilla.com/D1565
lib/pkcs12/p12e.c
--- a/lib/pkcs12/p12e.c
+++ b/lib/pkcs12/p12e.c
@@ -879,17 +879,19 @@ sec_PKCS12AddAttributeToBag(SEC_PKCS12Ex
     sec_PKCS12Attribute *attribute;
     void *mark = NULL, *dummy = NULL;
     SECOidData *oiddata = NULL;
     SECItem unicodeName = { siBuffer, NULL, 0 };
     void *src = NULL;
     unsigned int nItems = 0;
     SECStatus rv;
 
-    if (!safeBag || !p12ctxt) {
+    PORT_Assert(p12ctxt->arena == safeBag->arena);
+    if (!safeBag || !p12ctxt || p12ctxt->arena != safeBag->arena) {
+        PORT_SetError(SEC_ERROR_INVALID_ARGS);
         return SECFailure;
     }
 
     mark = PORT_ArenaMark(safeBag->arena);
 
     /* allocate the attribute */
     attribute = (sec_PKCS12Attribute *)PORT_ArenaZAlloc(safeBag->arena,
                                                         sizeof(sec_PKCS12Attribute));