1 | // RUN: %clangxx_msan -O0 %s -o %t && %run %t %p |
2 | // RUN: %clangxx_msan -O0 -D_FILE_OFFSET_BITS=64 %s -o %t && %run %t %p |
3 | // RUN: %clangxx_msan -O3 %s -o %t && %run %t %p |
4 | |
5 | #include <assert.h> |
6 | #include <glob.h> |
7 | #include <stdio.h> |
8 | #include <stdlib.h> |
9 | #include <string.h> |
10 | #include <errno.h> |
11 | |
12 | #include <sys/stat.h> |
13 | #include <sys/types.h> |
14 | #include <dirent.h> |
15 | #include <unistd.h> |
16 | |
17 | #include <sanitizer/msan_interface.h> |
18 | |
19 | |
20 | int main(int argc, char *argv[]) { |
21 | assert(argc == 2); |
22 | char buf[1024]; |
23 | snprintf(s: buf, maxlen: sizeof(buf), format: "%s/%s" , argv[1], "scandir_test_root/" ); |
24 | |
25 | struct dirent **d; |
26 | int res = scandir(dir: buf, namelist: &d, NULL, NULL); |
27 | assert(res >= 3); |
28 | assert(__msan_test_shadow(&d, sizeof(*d)) == (size_t)-1); |
29 | for (int i = 0; i < res; ++i) { |
30 | assert(__msan_test_shadow(&d[i], sizeof(d[i])) == (size_t)-1); |
31 | assert(__msan_test_shadow(d[i], d[i]->d_reclen) == (size_t)-1); |
32 | } |
33 | return 0; |
34 | } |
35 | |