X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/b3971512e61ecab68b17ca7ffe6c8c600310a026..refs/heads/master:/OSX/libsecurity_keychain/lib/SecItem.cpp diff --git a/OSX/libsecurity_keychain/lib/SecItem.cpp b/OSX/libsecurity_keychain/lib/SecItem.cpp index 2cdb17f9..e5b078ad 100644 --- a/OSX/libsecurity_keychain/lib/SecItem.cpp +++ b/OSX/libsecurity_keychain/lib/SecItem.cpp @@ -42,6 +42,7 @@ #include #include "utilities/array_size.h" #include "utilities/SecCFWrappers.h" +#include "LegacyAPICounts.h" #include #include @@ -71,8 +72,6 @@ OSStatus SecItemAdd_ios(CFDictionaryRef attributes, CFTypeRef *result); OSStatus SecItemCopyMatching_ios(CFDictionaryRef query, CFTypeRef *result); OSStatus SecItemUpdate_ios(CFDictionaryRef query, CFDictionaryRef attributesToUpdate); OSStatus SecItemDelete_ios(CFDictionaryRef query); -OSStatus SecItemUpdateTokenItems_ios(CFTypeRef tokenID, CFArrayRef tokenItemsAttributes); - OSStatus SecItemValidateAppleApplicationGroupAccess(CFStringRef group); CFDictionaryRef SecItemCopyTranslatedAttributes(CFDictionaryRef inOSXDict, CFTypeRef itemClass, @@ -3827,6 +3826,8 @@ AddItemResults(SecKeychainItemRef item, // // Note that we allocate *items if needed. + CFTypeRef localResult = NULL; + if (!item || !itemParams || !result) return errSecParam; @@ -3855,7 +3856,8 @@ AddItemResults(SecKeychainItemRef item, CFArrayAppendValue(itemArray, itemRef); } else { - *result = CFRetain((CFTypeRef)itemRef); + CFReleaseNull(localResult); + localResult = CFRetain((CFTypeRef)itemRef); } } @@ -3874,7 +3876,8 @@ AddItemResults(SecKeychainItemRef item, CFArrayAppendValue(itemArray, persistentRef); } else { - *result = CFRetain(persistentRef); + CFReleaseNull(localResult); + localResult = CFRetain(persistentRef); } CFRelease(persistentRef); } @@ -3898,7 +3901,8 @@ AddItemResults(SecKeychainItemRef item, CFArrayAppendValue(itemArray, dataRef); } else { - *result = CFRetain(dataRef); + CFReleaseNull(localResult); + localResult = CFRetain(dataRef); } CFRelease(dataRef); status = errSecSuccess; @@ -3920,7 +3924,8 @@ AddItemResults(SecKeychainItemRef item, CFArrayAppendValue(itemArray, dataRef); } else { - *result = CFRetain(dataRef); + CFReleaseNull(localResult); + localResult = CFRetain(dataRef); } CFRelease(dataRef); (void) SecKeychainItemFreeContent(NULL, data); @@ -3949,7 +3954,8 @@ AddItemResults(SecKeychainItemRef item, CFArrayAppendValue(itemArray, attrsDict); } else { - *result = CFRetain(attrsDict); + CFReleaseNull(localResult); + localResult = CFRetain(attrsDict); } CFRelease(attrsDict); } @@ -3962,14 +3968,22 @@ AddItemResults(SecKeychainItemRef item, if (itemArray) { CFArrayAppendValue(itemArray, itemDict); CFRelease(itemDict); - *result = itemArray; + CFReleaseNull(localResult); + localResult = itemArray; } else { - *result = itemDict; + CFReleaseNull(localResult); + localResult = itemDict; } } else if (itemArray) { - *result = itemArray; + CFReleaseNull(localResult); + localResult = itemArray; + } + + if (localResult) { + *result = localResult; + localResult = NULL; } return status; @@ -5082,14 +5096,6 @@ SecItemDelete(CFDictionaryRef query) return status; } -OSStatus -SecItemUpdateTokenItems(CFTypeRef tokenID, CFArrayRef tokenItemsAttributes) -{ - OSStatus status = SecItemUpdateTokenItems_ios(tokenID, tokenItemsAttributes); - secitemlog(LOG_NOTICE, "SecItemUpdateTokenItems_ios result: %d", status); - return status; -} - OSStatus SecItemCopyMatching_osx( CFDictionaryRef query, @@ -5100,6 +5106,8 @@ SecItemCopyMatching_osx( else *result = NULL; + setCountLegacyAPIEnabledForThread(false); + CFAllocatorRef allocator = CFGetAllocator(query); CFIndex matchCount = 0; CFMutableArrayRef itemArray = NULL; @@ -5144,20 +5152,9 @@ error_exit: } _FreeSecItemParams(itemParams); - return status; -} + setCountLegacyAPIEnabledForThread(true); -OSStatus -SecItemCopyDisplayNames( - CFArrayRef items, - CFArrayRef *displayNames) -{ - BEGIN_SECAPI - Required(items); - Required(displayNames); - //%%%TBI - return errSecUnimplemented; - END_SECAPI + return status; } OSStatus @@ -5170,6 +5167,8 @@ SecItemAdd_osx( else if (result) *result = NULL; + setCountLegacyAPIEnabledForThread(false); + CFAllocatorRef allocator = CFGetAllocator(attributes); CFMutableArrayRef itemArray = NULL; SecKeychainItemRef item = NULL; @@ -5303,6 +5302,7 @@ error_exit: *result = NULL; } _FreeSecItemParams(itemParams); + setCountLegacyAPIEnabledForThread(true); return status; } @@ -5330,6 +5330,8 @@ SecItemUpdate_osx( CFRelease(results); } + setCountLegacyAPIEnabledForThread(false); + OSStatus result = errSecSuccess; CFIndex ix, count = CFArrayGetCount(items); for (ix=0; ix < count; ix++) { @@ -5340,6 +5342,8 @@ SecItemUpdate_osx( } } + setCountLegacyAPIEnabledForThread(true); + if (items) { CFRelease(items); } @@ -5368,6 +5372,8 @@ SecItemDelete_osx( CFRelease(results); } + setCountLegacyAPIEnabledForThread(false); + OSStatus result = errSecSuccess; CFIndex ix, count = CFArrayGetCount(items); for (ix=0; ix < count; ix++) { @@ -5383,6 +5389,8 @@ SecItemDelete_osx( } } + setCountLegacyAPIEnabledForThread(true); + if (items) CFRelease(items);