blob: 57bc3fdbb63a4c866f180cea6e10b3e1f3422e1f [file] [log] [blame]
Ted Kremenek033a07e2011-08-03 23:14:55 +00001// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.osx.KeychainAPI %s -verify
Anna Zaksf57be282011-08-01 22:40:01 +00002
3// Fake typedefs.
4typedef unsigned int OSStatus;
5typedef unsigned int SecKeychainAttributeList;
6typedef unsigned int SecKeychainItemRef;
7typedef unsigned int SecItemClass;
8typedef unsigned int UInt32;
9typedef unsigned int CFTypeRef;
10typedef unsigned int UInt16;
11typedef unsigned int SecProtocolType;
12typedef unsigned int SecAuthenticationType;
13enum {
14 noErr = 0,
15 GenericError = 1
16};
17
18// Functions that allocate data.
19OSStatus SecKeychainItemCopyContent (
20 SecKeychainItemRef itemRef,
21 SecItemClass *itemClass,
22 SecKeychainAttributeList *attrList,
23 UInt32 *length,
24 void **outData
25);
26OSStatus SecKeychainFindGenericPassword (
27 CFTypeRef keychainOrArray,
28 UInt32 serviceNameLength,
29 const char *serviceName,
30 UInt32 accountNameLength,
31 const char *accountName,
32 UInt32 *passwordLength,
33 void **passwordData,
34 SecKeychainItemRef *itemRef
35);
36OSStatus SecKeychainFindInternetPassword (
37 CFTypeRef keychainOrArray,
38 UInt32 serverNameLength,
39 const char *serverName,
40 UInt32 securityDomainLength,
41 const char *securityDomain,
42 UInt32 accountNameLength,
43 const char *accountName,
44 UInt32 pathLength,
45 const char *path,
46 UInt16 port,
47 SecProtocolType protocol,
48 SecAuthenticationType authenticationType,
49 UInt32 *passwordLength,
50 void **passwordData,
51 SecKeychainItemRef *itemRef
52);
53
54// Function which frees data.
55OSStatus SecKeychainItemFreeContent (
56 SecKeychainAttributeList *attrList,
57 void *data
58);
59
60int foo () {
61 unsigned int *ptr = 0;
62 OSStatus st = 0;
63
64 UInt32 length;
65 void *outData;
66
67 st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &outData);
Anna Zakse68b5f12011-08-02 17:11:03 +000068 if (st == noErr)
69 SecKeychainItemFreeContent(ptr, outData);
Anna Zaksf57be282011-08-01 22:40:01 +000070
71 return 0;
72}