]> git.saurik.com Git - apple/security.git/blobdiff - OSX/libsecurity_keychain/lib/Item.cpp
Security-59754.80.3.tar.gz
[apple/security.git] / OSX / libsecurity_keychain / lib / Item.cpp
index bea27fec5077ffe1e6476bb256615fbd9c18aec4..f6720512bf26996e55579a6ea3a944b6f235b29c 100644 (file)
@@ -46,9 +46,7 @@
 #include <utilities/der_plist.h>
 
 #include <security_utilities/CSPDLTransaction.h>
 #include <utilities/der_plist.h>
 
 #include <security_utilities/CSPDLTransaction.h>
-#include <SecBasePriv.h>
-
-#define SENDACCESSNOTIFICATIONS 1
+#include <Security/SecBasePriv.h>
 
 //%%% schema indexes should be defined in Schema.h
 #define _kSecAppleSharePasswordItemClass               'ashp'
 
 //%%% schema indexes should be defined in Schema.h
 #define _kSecAppleSharePasswordItemClass               'ashp'
@@ -333,7 +331,7 @@ DbAttributes* ItemImpl::getCurrentAttributes() {
 
 void ItemImpl::encodeAttributes(CssmOwnedData &attributeBlob) {
     // Sometimes we don't have our attributes. Find them.
 
 void ItemImpl::encodeAttributes(CssmOwnedData &attributeBlob) {
     // Sometimes we don't have our attributes. Find them.
-    auto_ptr<DbAttributes> dbAttributes(getCurrentAttributes());
+    unique_ptr<DbAttributes> dbAttributes(getCurrentAttributes());
     encodeAttributesFromDictionary(attributeBlob, dbAttributes.get());
 
 }
     encodeAttributesFromDictionary(attributeBlob, dbAttributes.get());
 
 }
@@ -458,7 +456,7 @@ void ItemImpl::encodeAttributesFromDictionary(CssmOwnedData &attributeBlob, DbAt
 }
 
 void ItemImpl::computeDigest(CssmOwnedData &sha2) {
 }
 
 void ItemImpl::computeDigest(CssmOwnedData &sha2) {
-    auto_ptr<DbAttributes> dbAttributes(getCurrentAttributes());
+    unique_ptr<DbAttributes> dbAttributes(getCurrentAttributes());
     ItemImpl::computeDigestFromDictionary(sha2, dbAttributes.get());
 }
 
     ItemImpl::computeDigestFromDictionary(sha2, dbAttributes.get());
 }
 
@@ -595,7 +593,7 @@ bool ItemImpl::checkIntegrity(AclBearer& aclBearer) {
         return true;
     }
 
         return true;
     }
 
-    auto_ptr<DbAttributes> dbAttributes(getCurrentAttributes());
+    unique_ptr<DbAttributes> dbAttributes(getCurrentAttributes());
     return checkIntegrityFromDictionary(aclBearer, dbAttributes.get());
 }
 
     return checkIntegrityFromDictionary(aclBearer, dbAttributes.get());
 }
 
@@ -609,7 +607,7 @@ bool ItemImpl::checkIntegrityFromDictionary(AclBearer& aclBearer, DbAttributes*
         // them.
 
         AclEntryInfo &info = aclInfos.at(0);
         // them.
 
         AclEntryInfo &info = aclInfos.at(0);
-        auto_ptr<ACL> acl(new ACL(info, Allocator::standard()));
+        unique_ptr<ACL> acl(new ACL(info, Allocator::standard()));
 
         for(int i = 1; i < aclInfos.count(); i++) {
             secnotice("integrity", "*** DUPLICATE INTEGRITY ACL, something has gone wrong");
 
         for(int i = 1; i < aclInfos.count(); i++) {
             secnotice("integrity", "*** DUPLICATE INTEGRITY ACL, something has gone wrong");
@@ -1075,7 +1073,7 @@ ItemImpl::doChange(Keychain keychain, CSSM_DB_RECORDTYPE recordType, void (^tryC
     } catch (CssmError cssme) {
         // If there's a "duplicate" of this item, it might be an item with corrupt/invalid attributes
         // Try to extract the item and check its attributes, then try again if necessary
     } catch (CssmError cssme) {
         // If there's a "duplicate" of this item, it might be an item with corrupt/invalid attributes
         // Try to extract the item and check its attributes, then try again if necessary
-        auto_ptr<CssmClient::DbAttributes> primaryKeyAttrs;
+        unique_ptr<CssmClient::DbAttributes> primaryKeyAttrs;
         if(cssme.error == CSSMERR_DL_INVALID_UNIQUE_INDEX_DATA) {
             secnotice("integrity", "possible duplicate, trying to delete invalid items");
 
         if(cssme.error == CSSMERR_DL_INVALID_UNIQUE_INDEX_DATA) {
             secnotice("integrity", "possible duplicate, trying to delete invalid items");
 
@@ -1115,7 +1113,7 @@ ItemImpl::doChange(Keychain keychain, CSSM_DB_RECORDTYPE recordType, void (^tryC
 
                     // The item on-disk might have more or different attributes than we do, since we're
                     // only searching via primary key. Fetch all of its attributes.
 
                     // The item on-disk might have more or different attributes than we do, since we're
                     // only searching via primary key. Fetch all of its attributes.
-                    auto_ptr<DbAttributes>dbDupAttributes (new DbAttributes(kc->database(), 1));
+                    unique_ptr<DbAttributes>dbDupAttributes (new DbAttributes(kc->database(), 1));
                     fillDbAttributesFromSchema(*dbDupAttributes, recordType, kc);
 
                     // Occasionally this cursor won't return the item attributes (for an unknown reason).
                     fillDbAttributesFromSchema(*dbDupAttributes, recordType, kc);
 
                     // Occasionally this cursor won't return the item attributes (for an unknown reason).
@@ -1415,23 +1413,12 @@ ItemImpl::getContent(SecItemClass *itemClass, SecKeychainAttributeList *attrList
     {
                getLocalContent(attrList, length, outData);
        }
     {
                getLocalContent(attrList, length, outData);
        }
-
-       // Inform anyone interested that we are doing this
-#if SENDACCESSNOTIFICATIONS
-    if (outData)
-    {
-               secinfo("kcnotify", "ItemImpl::getContent(%p, %p, %p, %p) retrieved content",
-                       itemClass, attrList, length, outData);
-
-        KCEventNotifier::PostKeychainEvent(kSecDataAccessEvent, mKeychain, this);
-    }
-#endif
 }
 
 void
 ItemImpl::freeContent(SecKeychainAttributeList *attrList, void *data)
 {
 }
 
 void
 ItemImpl::freeContent(SecKeychainAttributeList *attrList, void *data)
 {
-    Allocator &allocator = Allocator::standard(); // @@@ This might not match the one used originally
+    Allocator &allocator = Allocator::standard(Allocator::sensitive); // @@@ This might not match the one used originally
     if (data)
                allocator.free(data);
 
     if (data)
                allocator.free(data);
 
@@ -1539,7 +1526,7 @@ ItemImpl::getAttributesAndData(SecKeychainAttributeInfo *info, SecItemClass *ite
             theList->count = 0;
             theList->attr = NULL;
         } else {
             theList->count = 0;
             theList->attr = NULL;
         } else {
-            SecKeychainAttribute *attr=reinterpret_cast<SecKeychainAttribute *>(malloc(sizeof(SecKeychainAttribute)*attrCount));
+            SecKeychainAttribute *attr=reinterpret_cast<SecKeychainAttribute *>(calloc(attrCount, sizeof(SecKeychainAttribute)));
             theList->count=attrCount;
             theList->attr=attr;
 
             theList->count=attrCount;
             theList->attr=attr;
 
@@ -1573,13 +1560,6 @@ ItemImpl::getAttributesAndData(SecKeychainAttributeInfo *info, SecItemClass *ite
 
                if (length) *length=(UInt32)itemData.length();
                itemData.Length=0;
 
                if (length) *length=(UInt32)itemData.length();
                itemData.Length=0;
-
-#if SENDACCESSNOTIFICATIONS
-               secinfo("kcnotify", "ItemImpl::getAttributesAndData(%p, %p, %p, %p, %p) retrieved data",
-                       info, itemClass, attrList, length, outData);
-
-               KCEventNotifier::PostKeychainEvent(kSecDataAccessEvent, mKeychain, this);
-#endif
        }
 
 }
        }
 
 }
@@ -1587,7 +1567,7 @@ ItemImpl::getAttributesAndData(SecKeychainAttributeInfo *info, SecItemClass *ite
 void
 ItemImpl::freeAttributesAndData(SecKeychainAttributeList *attrList, void *data)
 {
 void
 ItemImpl::freeAttributesAndData(SecKeychainAttributeList *attrList, void *data)
 {
-       Allocator &allocator = Allocator::standard(); // @@@ This might not match the one used originally
+       Allocator &allocator = Allocator::standard(Allocator::sensitive); // @@@ This might not match the one used originally
 
        if (data)
                allocator.free(data);
 
        if (data)
                allocator.free(data);
@@ -1740,13 +1720,6 @@ ItemImpl::getData(CssmDataContainer& outData)
        }
 
     getContent(NULL, &outData);
        }
 
     getContent(NULL, &outData);
-
-#if SENDACCESSNOTIFICATIONS
-    secinfo("kcnotify", "ItemImpl::getData retrieved data");
-
-       //%%%<might> be done elsewhere, but here is good for now
-       KCEventNotifier::PostKeychainEvent(kSecDataAccessEvent, mKeychain, this);
-#endif
 }
 
 SSGroup
 }
 
 SSGroup