blob: 7a584da6c05c3d6f6719a883cf5c60981b39fca9 [file] [log] [blame]
Argyrios Kyrtzidisc4d2c902011-02-28 19:49:42 +00001// RUN: %clang_cc1 -analyze -analyzer-checker=unix.experimental.Chroot -analyzer-store region -verify %s
Zhongxing Xu1c9e6b12010-10-10 05:45:30 +00002
3extern int chroot(const char* path);
4extern int chdir(const char* path);
5
6void foo(void) {
7}
8
9void f1(void) {
10 chroot("/usr/local"); // root changed.
11 foo(); // expected-warning {{No call of chdir("/") immediately after chroot}}
12}
13
14void f2(void) {
15 chroot("/usr/local"); // root changed.
16 chdir("/"); // enter the jail.
17 foo(); // no-warning
18}
19
20void f3(void) {
21 chroot("/usr/local"); // root changed.
22 chdir("../"); // change working directory, still out of jail.
23 foo(); // expected-warning {{No call of chdir("/") immediately after chroot}}
24}