aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2011-08-13 02:10:15 +0000
committerAnna Zaks <ganna@apple.com>2011-08-13 02:10:15 +0000
commitf7ce52b0995efd65d51a3359939c09022a23e04c (patch)
tree0dfc5d420c79b846d818f3d31ccb0d5877944a24 /test
parentb18d503bc939281d8ea0dacea44e847297b92e8d (diff)
MacOSKeychainAPIChecker: Test all APIs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137549 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Analysis/keychainAPI.m33
1 files changed, 24 insertions, 9 deletions
diff --git a/test/Analysis/keychainAPI.m b/test/Analysis/keychainAPI.m
index 74834ab5d5..7a7fcf0cce 100644
--- a/test/Analysis/keychainAPI.m
+++ b/test/Analysis/keychainAPI.m
@@ -135,15 +135,26 @@ void* returnContent() {
// Password was passed in as an argument and does nt have to be deleted.
OSStatus getPasswordAndItem(void** password, UInt32* passwordLength) {
- OSStatus err;
- SecKeychainItemRef item;
- err = SecKeychainFindGenericPassword(0, 3, "xx",
- 3, "xx",
- passwordLength, password,
- &item);
- return err;
+ OSStatus err;
+ SecKeychainItemRef item;
+ err = SecKeychainFindGenericPassword(0, 3, "xx", 3, "xx",
+ passwordLength, password, &item);
+ return err;
} // no-warning
+// Make sure we do not report an error if we call free only if password != 0.
+OSStatus testSecKeychainFindGenericPassword(UInt32* passwordLength) {
+ OSStatus err;
+ SecKeychainItemRef item;
+ void *password;
+ err = SecKeychainFindGenericPassword(0, 3, "xx", 3, "xx",
+ passwordLength, &password, &item);
+ if (err == noErr && password) {
+ SecKeychainItemFreeContent(0, password);
+ }
+ return err;
+}
+
int apiMismatch(SecKeychainItemRef itemRef,
SecKeychainAttributeInfo *info,
SecItemClass *itemClass) {
@@ -183,14 +194,18 @@ int ErrorCodesFromDifferentAPISDoNotInterfere(SecKeychainItemRef itemRef,
return 0; // expected-warning{{Allocated data is not released: missing a call to 'SecKeychainItemFreeAttributesAndData'}}
}
-int foo() {
+int foo(CFTypeRef keychainOrArray, SecProtocolType protocol,
+ SecAuthenticationType authenticationType, SecKeychainItemRef *itemRef) {
unsigned int *ptr = 0;
OSStatus st = 0;
UInt32 length;
void *outData[5];
- st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &(outData[3]));
+ st = SecKeychainFindInternetPassword(keychainOrArray,
+ 16, "server", 16, "domain", 16, "account",
+ 16, "path", 222, protocol, authenticationType,
+ &length, &(outData[3]), itemRef);
if (length == 5) {
if (st == noErr)
SecKeychainItemFreeContent(ptr, outData[3]);