diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-01-20 05:35:06 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-01-20 05:35:06 +0000 |
commit | b63d8d8f7b2d101838af992749411dd79c2ed116 (patch) | |
tree | 9d6e9f5c7e3998b48a0f630f16119b02ed1d42de /test/Analysis/security-syntax-checks.m | |
parent | 76a54246dbbe6cc3c74186e64f8ea0deb4a64ea2 (diff) | |
download | clang-b63d8d8f7b2d101838af992749411dd79c2ed116.tar.gz |
Implement checker that looks for calls to mktemps and friends that have fewer than 6 Xs. Implements <rdar://problem/6336672>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148531 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/security-syntax-checks.m')
-rw-r--r-- | test/Analysis/security-syntax-checks.m | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/Analysis/security-syntax-checks.m b/test/Analysis/security-syntax-checks.m index 7c0cda3c79..b392bd1ea6 100644 --- a/test/Analysis/security-syntax-checks.m +++ b/test/Analysis/security-syntax-checks.m @@ -175,3 +175,25 @@ pid_t vfork(void); void test_vfork() { vfork(); //expected-warning{{Call to function 'vfork' is insecure as it can lead to denial of service situations in the parent process.}} } + +//===----------------------------------------------------------------------=== +// mkstemp() +//===----------------------------------------------------------------------=== + +char *mkdtemp(char *template); +int mkstemps(char *template, int suffixlen); +int mkstemp(char *template); +char *mktemp(char *template); + +void test_mkstemp() { + mkstemp("XX"); // expected-warning {{Call to 'mkstemp' should have at least 6 'X's in the format string to be secure (2 'X's seen)}} + mkstemp("XXXXXX"); + mkstemp("XXXXXXX"); + mkstemps("XXXXXX", 0); + mkstemps("XXXXXX", 1); // expected-warning {{5 'X's seen}} + mkstemps("XXXXXX", 2); // expected-warning {{Call to 'mkstemps' should have at least 6 'X's in the format string to be secure (4 'X's seen, 2 characters used as a suffix)}} + mkdtemp("XX"); // expected-warning {{2 'X's seen}} + mkstemp("X"); // expected-warning {{Call to 'mkstemp' should have at least 6 'X's in the format string to be secure (1 'X' seen)}} + mkdtemp("XXXXXX"); +} + |