21 lines · c
1// RUN: %clang_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s2// RUN: %env_asan_opts=check_printf=1 %run %t 2>&1 | FileCheck %s3 4// REQUIRES: freebsd || netbsd5 6#include <unistd.h>7 8int main() {9 const char fmt[2] = "%s%d\n";10 setproctitle("%s", "setproctitle");11 setproctitle("%c%c%c", 'c', "a", 'e');12 setproctitle(fmt, "abcdef", -5);13 return 0;14}15 16// CHECK: ERROR: AddressSanitizer: stack-buffer-overflow17// CHECK-NEXT: READ of size {{[0-9]+}} at {{.*}}18// CHECK: #0 {{.*}} printf_common19// CHECK: #1 {{.*}} setproctitle20// CHECK: #2 {{.*}} main21