]> git.saurik.com Git - apple/security.git/blobdiff - libsecurity_smime/lib/cmssiginfo.c
Security-57031.40.6.tar.gz
[apple/security.git] / libsecurity_smime / lib / cmssiginfo.c
index 41ab2e23638b9cd82dfdab5e465def045c26c941..8fe415b3b12b2d4573e28091f3277e2075301e8f 100644 (file)
@@ -141,18 +141,15 @@ DER_CFDateToUTCTime(CFAbsoluteTime date, SecAsn1Item * utcTime)
     utcTime->Data = d = PORT_Alloc(13);
     if (!utcTime->Data)
        return SECFailure;
-
-    int year;
-    int month;
-    int day;
-    int hour;
-    int minute;
-    int second;
     
-    if (!CFCalendarDecomposeAbsoluteTime(SecCFCalendarGetZulu(), date, "yMdHms", &year, &month, &day, &hour, &minute, &second))
+    __block int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
+    __block bool result;
+    SecCFCalendarDoWithZuluCalendar(^(CFCalendarRef zuluCalendar) {
+        result = CFCalendarDecomposeAbsoluteTime(zuluCalendar, date, "yMdHms", &year, &month, &day, &hour, &minute, &second);
+    });
+    if (!result)
         return SECFailure;
 
-
     /* UTC time does not handle the years before 1950 */
     if (year < 1950)
         return SECFailure;
@@ -323,7 +320,7 @@ SecCmsSignerInfoSign(SecCmsSignerInfoRef signerinfo, SecAsn1Item * digest, SecAs
     SECOidTag pubkAlgTag;
     SecAsn1Item signature = { 0 };
     OSStatus rv;
-    PLArenaPool *poolp, *tmppoolp;
+    PLArenaPool *poolp, *tmppoolp = NULL;
     const SECAlgorithmID *algID = NULL;
     //CERTSubjectPublicKeyInfo *spki;
 
@@ -447,6 +444,7 @@ SecCmsSignerInfoSign(SecCmsSignerInfoRef signerinfo, SecAsn1Item * digest, SecAs
 #endif
 
        PORT_FreeArena(tmppoolp, PR_FALSE); /* awkward memory management :-( */
+       tmppoolp = 0;
     } else {
         signature.Length = SecKeyGetSize(privkey, kSecKeySignatureSize);
         signature.Data = PORT_ZAlloc(signature.Length);
@@ -484,6 +482,8 @@ loser:
        SECITEM_FreeItem (&signature, PR_FALSE);
     if (privkey)
        SECKEY_DestroyPrivateKey(privkey);
+    if (tmppoolp)
+       PORT_FreeArena(tmppoolp, PR_FALSE);
     return SECFailure;
 }