diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-10-10 05:45:30 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-10-10 05:45:30 +0000 |
commit | 271c9c7b6dcb22a22ad0f6c12f02ca3b96a5ead1 (patch) | |
tree | ef65504ea8a05c611a89650d447aef99a4aa14b9 /clang/test/Analysis/chroot.c | |
parent | 073c9cb592e7fbd981a0814f39b97375c81a684e (diff) | |
download | bcm5719-llvm-271c9c7b6dcb22a22ad0f6c12f02ca3b96a5ead1.tar.gz bcm5719-llvm-271c9c7b6dcb22a22ad0f6c12f02ca3b96a5ead1.zip |
Add experimental chroot check which checks improper use of chroot(). Patch by
Lei Zhang.
llvm-svn: 116163
Diffstat (limited to 'clang/test/Analysis/chroot.c')
-rw-r--r-- | clang/test/Analysis/chroot.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/clang/test/Analysis/chroot.c b/clang/test/Analysis/chroot.c new file mode 100644 index 00000000000..a0ee4504965 --- /dev/null +++ b/clang/test/Analysis/chroot.c @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-experimental-checks -analyzer-store region -verify %s + +extern int chroot(const char* path); +extern int chdir(const char* path); + +void foo(void) { +} + +void f1(void) { + chroot("/usr/local"); // root changed. + foo(); // expected-warning {{No call of chdir("/") immediately after chroot}} +} + +void f2(void) { + chroot("/usr/local"); // root changed. + chdir("/"); // enter the jail. + foo(); // no-warning +} + +void f3(void) { + chroot("/usr/local"); // root changed. + chdir("../"); // change working directory, still out of jail. + foo(); // expected-warning {{No call of chdir("/") immediately after chroot}} +} |