1 // RUN: %clangxx_msan %s -o %t
2 // RUN: %run %t --disable-checks 0 2>&1 | FileCheck --check-prefix=DISABLED --allow-empty %s
3 // RUN: %run %t --disable-checks 1 2>&1 | FileCheck --check-prefix=DISABLED --allow-empty %s
4 // RUN: %run %t --disable-checks 2 2>&1 | FileCheck --check-prefix=DISABLED --allow-empty %s
5 // RUN: %run %t --disable-checks 3 2>&1 | FileCheck --check-prefix=DISABLED --allow-empty %s
6 // RUN: not %run %t --reenable-checks 0 2>&1 | FileCheck --check-prefix=CASE-0 %s
7 // RUN: not %run %t --reenable-checks 1 2>&1 | FileCheck --check-prefix=CASE-1 %s
8 // RUN: not %run %t --reenable-checks 2 2>&1 | FileCheck --check-prefix=CASE-2 %s
9 // RUN: not %run %t --reenable-checks 3 2>&1 | FileCheck --check-prefix=CASE-3 %s
15 #include <sanitizer/msan_interface.h>
17 int main(int argc
, char *argv
[]) {
19 __msan_scoped_disable_interceptor_checks();
20 if (strcmp(argv
[1], "--reenable-checks") == 0)
21 __msan_scoped_enable_interceptor_checks();
26 char *copy
= strndup(uninit
, sizeof(uninit
)); // BOOM
29 // CASE-0: Uninitialized bytes in strndup
33 puts(uninit
); // Ensure previous call did not enable interceptor checks.
35 // CASE-1: Uninitialized bytes in puts
38 int cmp
= memcmp(uninit
, uninit
, sizeof(uninit
)); // BOOM
40 // CASE-2: Uninitialized bytes in MemcmpInterceptorCommon
43 size_t len
= strlen(uninit
); // BOOM
45 // CASE-3: Uninitialized bytes in strlen
49 // DISABLED-NOT: Uninitialized bytes