Reproducible with any call to readdir or scandir from wasi-libc.
I believe the issue is this line: https://github.com/cjihrig/uvwasi/blob/d3fe61d/src/uvwasi.c#L1392
/* Write the entry name to the buffer. */
available = buf_len - *bufused;
size_to_cp = name_len > available ? available : name_len;
memcpy((char*)buf + *bufused, &dirents[i].name, size_to_cp); // bad memcpy
*bufused += size_to_cp;
It appears uvwasi is calling memcpy on a pointer to the name string, not the string itself.
Reproducible with any call to
readdirorscandirfrom wasi-libc.I believe the issue is this line: https://github.com/cjihrig/uvwasi/blob/d3fe61d/src/uvwasi.c#L1392
It appears uvwasi is calling memcpy on a pointer to the name string, not the string itself.