#include "Globals.h"
#include "StorageManager.h"
#include <Security/SecKeychainItemPriv.h>
-#include <SecBase.h>
+#include <Security/SecBase.h>
#include <Security/SecBasePriv.h>
+#include <utilities/array_size.h>
using namespace KeychainCore;
using namespace CssmClient;
mAllFailed(true),
mDeleteInvalidRecords(false),
mIsNewKeychain(true),
- mMutex(Mutex::recursive),
- mKeychainReadLock(NULL)
+ mMutex(Mutex::recursive)
{
recordType(Schema::recordTypeFor(itemClass));
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];
}
mAllFailed(true),
mDeleteInvalidRecords(false),
mIsNewKeychain(true),
- mMutex(Mutex::recursive),
- mKeychainReadLock(NULL)
+ mMutex(Mutex::recursive)
{
if (!attrList) // No additional selectionPredicates: we are done
return;
}
}
-KCCursorImpl::~KCCursorImpl() throw()
+KCCursorImpl::~KCCursorImpl() _NOEXCEPT
{
- if(mKeychainReadLock) {
- delete mKeychainReadLock;
- }
}
//static ModuleNexus<Mutex> gActivationMutex;
}
Keychain &kc = *mCurrent;
+
Mutex* mutex = kc->getKeychainMutex();
StLock<Mutex> _(*mutex);
}
}
}
- // release the Keychain lock before checking item integrity to avoid deadlock
item = tempItem;
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