X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/fa7225c82381bac4432a6edf16f53b5370238d85..07691282a056c4efea71e1e505527601e8cc166b:/OSX/libsecurity_keychain/lib/KCCursor.cpp diff --git a/OSX/libsecurity_keychain/lib/KCCursor.cpp b/OSX/libsecurity_keychain/lib/KCCursor.cpp index b252dd9c..a5d25d96 100644 --- a/OSX/libsecurity_keychain/lib/KCCursor.cpp +++ b/OSX/libsecurity_keychain/lib/KCCursor.cpp @@ -37,6 +37,7 @@ #include #include #include +#include using namespace KeychainCore; using namespace CssmClient; @@ -61,8 +62,7 @@ KCCursorImpl::KCCursorImpl(const StorageManager::KeychainList &searchList, SecIt mAllFailed(true), mDeleteInvalidRecords(false), mIsNewKeychain(true), - mMutex(Mutex::recursive), - mKeychainReadLock(NULL) + mMutex(Mutex::recursive) { recordType(Schema::recordTypeFor(itemClass)); @@ -75,8 +75,9 @@ KCCursorImpl::KCCursorImpl(const StorageManager::KeychainList &searchList, SecIt for (const SecKeychainAttribute *attr=attrList->attr; attr != end; ++attr) { const CSSM_DB_ATTRIBUTE_INFO *temp; - - if (attr->tag <' ') // ok, is this a key schema? Handle differently, just because we can... + + // ok, is this a key schema? Handle differently, just because we can... + if (attr->tag <' ' && attr->tag < array_size(gKeyAttributeLookupTable)) { temp = gKeyAttributeLookupTable[attr->tag]; } @@ -119,8 +120,7 @@ KCCursorImpl::KCCursorImpl(const StorageManager::KeychainList &searchList, const mAllFailed(true), mDeleteInvalidRecords(false), mIsNewKeychain(true), - mMutex(Mutex::recursive), - mKeychainReadLock(NULL) + mMutex(Mutex::recursive) { if (!attrList) // No additional selectionPredicates: we are done return; @@ -174,9 +174,6 @@ KCCursorImpl::KCCursorImpl(const StorageManager::KeychainList &searchList, const KCCursorImpl::~KCCursorImpl() throw() { - if(mKeychainReadLock) { - delete mKeychainReadLock; - } } //static ModuleNexus gActivationMutex; @@ -226,6 +223,7 @@ KCCursorImpl::next(Item &item) } Keychain &kc = *mCurrent; + Mutex* mutex = kc->getKeychainMutex(); StLock _(*mutex); @@ -322,7 +320,6 @@ KCCursorImpl::next(Item &item) } } } - // release the Keychain lock before checking item integrity to avoid deadlock item = tempItem; @@ -370,18 +367,9 @@ void KCCursorImpl::newKeychain(StorageManager::KeychainList::iterator kcIter) { return; } - // Always lose the last keychain's lock - if(mKeychainReadLock) { - delete mKeychainReadLock; - mKeychainReadLock = NULL; - } - if(kcIter != mSearchList.end()) { (*kcIter)->performKeychainUpgradeIfNeeded(); (*kcIter)->tickle(); - - // Grab a read lock on the keychain - mKeychainReadLock = new StReadWriteLock(*((*kcIter)->getKeychainReadWriteLock()), StReadWriteLock::Read); } // Mark down that this function has been called