https://github.com/epiqc/ScaffCC
Raw File
Tip revision: 861c8b60980b0f4d36b101b45346a2e64b0fa390 authored by Pranav Gokhale on 05 February 2018, 05:29:11 UTC
update documentation and release notes
Tip revision: 861c8b6
chroot.c
// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.unix.Chroot -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}}
}
back to top