1 // RUN: %clang_cc1 -analyze -analyzer-checker=unix.experimental.Chroot -analyzer-store region -verify %s 2 3 extern int chroot(const char* path); 4 extern int chdir(const char* path); 5 foo(void)6void foo(void) { 7 } 8 f1(void)9void f1(void) { 10 chroot("/usr/local"); // root changed. 11 foo(); // expected-warning {{No call of chdir("/") immediately after chroot}} 12 } 13 f2(void)14void f2(void) { 15 chroot("/usr/local"); // root changed. 16 chdir("/"); // enter the jail. 17 foo(); // no-warning 18 } 19 f3(void)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 } 25