37 lines · plain
1// RUN: %clang_analyze_cc1 -triple thumbv7-apple-ios11.0 -verify=available \2// RUN: -analyzer-checker=security.insecureAPI.decodeValueOfObjCType %s3// RUN: %clang_analyze_cc1 -triple thumbv7-apple-ios10.0 -verify=notavailable \4// RUN: -analyzer-checker=security.insecureAPI.decodeValueOfObjCType %s5// RUN: %clang_analyze_cc1 -triple x86_64-apple-macos10.13 -verify=available \6// RUN: -analyzer-checker=security.insecureAPI.decodeValueOfObjCType %s7// RUN: %clang_analyze_cc1 -triple x86_64-apple-macos10.12 -verify=notavailable \8// RUN: -analyzer-checker=security.insecureAPI.decodeValueOfObjCType %s9// RUN: %clang_analyze_cc1 -triple thumbv7-apple-watchos4.0 -verify=available \10// RUN: -analyzer-checker=security.insecureAPI.decodeValueOfObjCType %s11// RUN: %clang_analyze_cc1 -triple thumbv7-apple-watchos3.0 -verify=notavailable \12// RUN: -analyzer-checker=security.insecureAPI.decodeValueOfObjCType %s13// RUN: %clang_analyze_cc1 -triple thumbv7-apple-tvos11.0 -verify=available \14// RUN: -analyzer-checker=security.insecureAPI.decodeValueOfObjCType %s15// RUN: %clang_analyze_cc1 -triple thumbv7-apple-tvos10.0 -verify=notavailable \16// RUN: -analyzer-checker=security.insecureAPI.decodeValueOfObjCType %s17 18// notavailable-no-diagnostics19 20typedef unsigned long NSUInteger;21 22@interface NSCoder23- (void)decodeValueOfObjCType:(const char *)type24 at:(void *)data;25- (void)decodeValueOfObjCType:(const char *)type26 at:(void *)data27 size:(NSUInteger)size;28@end29 30void test(NSCoder *decoder) {31 // This would be a vulnerability on 64-bit platforms32 // but not on 32-bit platforms.33 NSUInteger x;34 [decoder decodeValueOfObjCType:"I" at:&x]; // available-warning{{Deprecated method '-decodeValueOfObjCType:at:' is insecure as it can lead to potential buffer overflows. Use the safer '-decodeValueOfObjCType:at:size:' method}}35 [decoder decodeValueOfObjCType:"I" at:&x size:sizeof(x)]; // no-warning36}37