]> git.saurik.com Git - apple/security.git/blobdiff - OSX/libsecurity_keychain/lib/Item.cpp
Security-57740.51.3.tar.gz
[apple/security.git] / OSX / libsecurity_keychain / lib / Item.cpp
index 079074235e1c8ba8798a36d2cb10354e8c5e663d..dad801c55dd821ae0a4c38afebe098fe9e9fc44a 100644 (file)
@@ -77,8 +77,8 @@ ItemImpl *ItemImpl::required(SecKeychainItemRef ptr)
 
 ItemImpl *ItemImpl::optional(SecKeychainItemRef ptr)
 {
-    if (SecCFObject *p = KeyItem::fromSecKeyRef(ptr)) {
-        return dynamic_cast<ItemImpl *>(p);
+    if (ptr != NULL && CFGetTypeID(ptr) == SecKeyGetTypeID()) {
+        return dynamic_cast<ItemImpl *>(KeyItem::fromSecKeyRef(ptr));
     } else if (SecCFObject *p = SecCFObject::optional(ptr)) {
         if (ItemImpl *pp = dynamic_cast<ItemImpl *>(p)) {
             return pp;
@@ -470,8 +470,6 @@ void ItemImpl::computeDigestFromDictionary(CssmOwnedData &sha2, DbAttributes* db
 }
 
 void ItemImpl::addIntegrity(Access &access, bool force) {
-    secnotice("integrity", "called");
-
     if(!force && (!mKeychain || !mKeychain->hasIntegrityProtection())) {
         secnotice("integrity", "skipping integrity add due to keychain version\n");
         return;
@@ -881,8 +879,6 @@ ItemImpl::updateSSGroup(Db& db, CSSM_DB_RECORDTYPE recordType, CssmDataContainer
     AclFactory aclFactory;
     const AccessCredentials *nullCred = aclFactory.nullCred();
 
-    secnotice("integrity", "called");
-
     bool haveOldUniqueId = !!mUniqueId.get();
     SSDbUniqueRecord ssUniqueId(NULL);
     SSGroup ssGroup(NULL);
@@ -1318,6 +1314,8 @@ void
 ItemImpl::modifyContent(const SecKeychainAttributeList *attrList, UInt32 dataLength, const void *inData)
 {
        StLock<Mutex>_(mMutex);
+    unique_ptr<StReadWriteLock> __(mKeychain == NULL ? NULL : new StReadWriteLock(*(mKeychain->getKeychainReadWriteLock()), StReadWriteLock::Write));
+
        if (!mDbAttributes.get())
        {
                mDbAttributes.reset(new DbAttributes());