1 | // RUN: %clang_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s |
2 | // RUN: %env_asan_opts=check_printf=1 %run %t 2>&1 | FileCheck %s |
3 | |
4 | // REQUIRES: freebsd || netbsd |
5 | |
6 | #include <unistd.h> |
7 | |
8 | int 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-overflow |
17 | // CHECK-NEXT: READ of size {{[0-9]+}} at {{.*}} |
18 | // CHECK: #0 {{.*}} printf_common |
19 | // CHECK: #1 {{.*}} setproctitle |
20 | // CHECK: #2 {{.*}} main |
21 | |