]> git.saurik.com Git - apple/security.git/blobdiff - OSX/libsecurity_smime/lib/cmsattr.c
Security-58286.260.20.tar.gz
[apple/security.git] / OSX / libsecurity_smime / lib / cmsattr.c
index 496039920a48721b0c89baa176f8e4f78ab393ac..8497904bf27fa496505b74cfadd8b64543d57e58 100644 (file)
@@ -111,19 +111,23 @@ loser:
 OSStatus
 SecCmsAttributeAddValue(PLArenaPool *poolp, SecCmsAttribute *attr, CSSM_DATA_PTR value)
 {
-    CSSM_DATA copiedvalue;
+    CSSM_DATA_PTR copiedvalue;
     void *mark;
 
     PORT_Assert (poolp != NULL);
 
     mark = PORT_ArenaMark(poolp);
 
-    /* XXX we need an object memory model #$%#$%! */
-    if (SECITEM_CopyItem(poolp, &copiedvalue, value) != SECSuccess)
-       goto loser;
+    if (value != NULL) {
+        if ((copiedvalue = SECITEM_AllocItem(poolp, NULL, value->Length)) == NULL)
+            goto loser;
 
-    if (SecCmsArrayAdd(poolp, (void ***)&(attr->values), (void *)&copiedvalue) != SECSuccess)
-       goto loser;
+        if (SECITEM_CopyItem(poolp, copiedvalue, value) != SECSuccess)
+            goto loser;
+
+        if (SecCmsArrayAdd(poolp, (void ***)&(attr->values), (void *)copiedvalue) != SECSuccess)
+            goto loser;
+    }
 
     PORT_ArenaUnmark(poolp, mark);
     return SECSuccess;
@@ -202,7 +206,7 @@ SecCmsAttributeCompareValue(SecCmsAttribute *attr, CSSM_DATA_PTR av)
  * helper function for dynamic template determination of the attribute value
  */
 static const SecAsn1Template *
-cms_attr_choose_attr_value_template(void *src_or_dest, Boolean encoding, const char *buf, void *dest)
+cms_attr_choose_attr_value_template(void *src_or_dest, Boolean encoding, const char *buf, size_t len, void *dest)
 {
     const SecAsn1Template *theTemplate;
     SecCmsAttribute *attribute;
@@ -234,6 +238,7 @@ cms_attr_choose_attr_value_template(void *src_or_dest, Boolean encoding, const c
        switch (oiddata->offset) {
        case SEC_OID_PKCS9_SMIME_CAPABILITIES:
        case SEC_OID_SMIME_ENCRYPTION_KEY_PREFERENCE:
+       case SEC_OID_APPLE_HASH_AGILITY_V2:
            /* these guys need to stay DER-encoded */
        default:
            /* same goes for OIDs that are not handled here */
@@ -252,10 +257,12 @@ cms_attr_choose_attr_value_template(void *src_or_dest, Boolean encoding, const c
            theTemplate = SEC_ASN1_GET(kSecAsn1ObjectIDTemplate);
            break;
        case SEC_OID_PKCS9_MESSAGE_DIGEST:
+        case SEC_OID_APPLE_HASH_AGILITY:
            encoded = PR_FALSE;
            theTemplate = SEC_ASN1_GET(kSecAsn1OctetStringTemplate);
            break;
        case SEC_OID_PKCS9_SIGNING_TIME:
+       case SEC_OID_APPLE_EXPIRATION_TIME:
            encoded = PR_FALSE;
            theTemplate = SEC_ASN1_GET(kSecAsn1UTCTimeTemplate); // @@@ This should be a choice between UTCTime and GeneralizedTime -- mb
            break;