]>
git.saurik.com Git - apple/security.git/blob - OSX/sec/Security/Regressions/secitem/si-80-empty-data.c
2 * Copyright (c) 2014 Apple Inc. All Rights Reserved.
5 #include <CoreFoundation/CoreFoundation.h>
6 #include <Security/SecItem.h>
7 #include <Security/SecBase.h>
8 #include <utilities/array_size.h>
9 #include <utilities/SecCFWrappers.h>
13 #include "Security_regressions.h"
15 /* Test <rdar://problem/16669564>
16 Retrieving attributes and data when item contains no data crashed.
19 static void tests(void)
21 CFDictionaryRef item
= CFDictionaryCreateForCFTypes(NULL
,
22 kSecClass
, kSecClassGenericPassword
,
23 kSecAttrAccount
, CFSTR("empty-data-account-test"),
24 kSecAttrService
, CFSTR("empty-data-svce-test"),
26 ok_status(SecItemAdd(item
, NULL
), "add generic password");
28 CFDictionaryRef query
= CFDictionaryCreateForCFTypes(NULL
,
29 kSecClass
, kSecClassGenericPassword
,
30 kSecAttrService
, CFSTR("empty-data-svce-test"),
31 kSecMatchLimit
, kSecMatchLimitAll
,
32 kSecReturnData
, kCFBooleanTrue
,
33 kSecReturnAttributes
, kCFBooleanTrue
,
36 ok_status(SecItemCopyMatching(query
, &result
), "query generic password");
37 ok(isArray(result
) && CFArrayGetCount(result
) == 1, "return 1-sized array of results");
38 CFDictionaryRef row
= CFArrayGetValueAtIndex(result
, 0);
39 ok(isDictionary(row
), "array row is dictionary");
40 ok(CFDictionaryGetValue(row
, kSecValueData
) == NULL
, "result contains no data");
41 ok(CFEqual(CFDictionaryGetValue(row
, kSecAttrService
), CFSTR("empty-data-svce-test")), "svce attribute is returned");
42 ok(CFEqual(CFDictionaryGetValue(row
, kSecAttrAccount
), CFSTR("empty-data-account-test")), "account attribute is returned");
46 query
= CFDictionaryCreateForCFTypes(NULL
,
47 kSecClass
, kSecClassGenericPassword
,
48 kSecAttrService
, CFSTR("empty-data-svce-test"),
50 ok_status(SecItemDelete(query
), "delete testing item");
56 int si_80_empty_data(int argc
, char *const *argv
)