Issue 163923
Summary [clang][analyzer] scandirat is not intercepted
Labels clang
Assignees
Reporter alxchk
    ```
#define _GNU_SOURCE
#include <dirent.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>

int filter(const struct dirent *d) {
        return strlen(d->d_name) > 2;
}

int
main(void)
{
    struct dirent **namelist;
    int n;

 n = scandirat(AT_FDCWD, ".", &namelist, filter, alphasort);
    if (n == -1) {
        perror("scandir");
        exit(EXIT_FAILURE);
    }

 while (n--) {
        printf("%s (%lu)\n", namelist[n]->d_name, strlen(namelist[n]->d_name));
        free(namelist[n]);
    }
 free(namelist);

    exit(EXIT_SUCCESS);
}
```

```
> clang -o /tmp/test test.c -fsanitize=memory -Wno-error
> /tmp/test
Uninitialized bytes in strlen at offset 0 inside [0x72d000000043, 2)
==374088==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x55b4602f2d3c in filter (/tmp/test+0x109d3c)
    #1 0x7f5179f5ee8a  (/usr/lib64/libc.so.6+0xc7e8a)
 #2 0x55b4602f2e48 in main (/tmp/test+0x109e48)
    #3 0x7f5179ebd166 (/usr/lib64/libc.so.6+0x26166)
    #4 0x7f5179ebd216 in __libc_start_main (/usr/lib64/libc.so.6+0x26216)
    #5 0x55b460257170 in _start (/tmp/test+0x6e170)

SUMMARY: MemorySanitizer: use-of-uninitialized-value (/tmp/test+0x109d3c) in filter
Exiting
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to