/* 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
readdir
orscandir
from 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.