Skip to content

uvwasi_fd_readdir returns garbage for dirent names #148

@chjj

Description

@chjj

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions