Ted Kremenek | 033a07e | 2011-08-03 23:14:55 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -analyze -analyzer-checker=experimental.osx.KeychainAPI %s -verify |
Anna Zaks | f57be28 | 2011-08-01 22:40:01 +0000 | [diff] [blame] | 2 | |
| 3 | // Fake typedefs. |
| 4 | typedef unsigned int OSStatus; |
| 5 | typedef unsigned int SecKeychainAttributeList; |
| 6 | typedef unsigned int SecKeychainItemRef; |
| 7 | typedef unsigned int SecItemClass; |
| 8 | typedef unsigned int UInt32; |
| 9 | typedef unsigned int CFTypeRef; |
| 10 | typedef unsigned int UInt16; |
| 11 | typedef unsigned int SecProtocolType; |
| 12 | typedef unsigned int SecAuthenticationType; |
| 13 | enum { |
| 14 | noErr = 0, |
| 15 | GenericError = 1 |
| 16 | }; |
| 17 | |
| 18 | // Functions that allocate data. |
| 19 | OSStatus SecKeychainItemCopyContent ( |
| 20 | SecKeychainItemRef itemRef, |
| 21 | SecItemClass *itemClass, |
| 22 | SecKeychainAttributeList *attrList, |
| 23 | UInt32 *length, |
| 24 | void **outData |
| 25 | ); |
| 26 | OSStatus 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 | ); |
| 36 | OSStatus 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. |
| 55 | OSStatus SecKeychainItemFreeContent ( |
| 56 | SecKeychainAttributeList *attrList, |
| 57 | void *data |
| 58 | ); |
| 59 | |
| 60 | int 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 Zaks | e68b5f1 | 2011-08-02 17:11:03 +0000 | [diff] [blame] | 68 | if (st == noErr) |
| 69 | SecKeychainItemFreeContent(ptr, outData); |
Anna Zaks | f57be28 | 2011-08-01 22:40:01 +0000 | [diff] [blame] | 70 | |
| 71 | return 0; |
| 72 | } |