Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
fd_readdir
to properly truncate directory entry names.
Previously, `fd_readdir` was truncating directory entry names based on the calculation of `min(name_len, buf_len - bufused)`, but `bufused` was not being updated after writing in the `dirent` structure to the buffer. This allowed `bufused` to be incremented beyond `buf_len` and returned as the number of bytes written to the buffer, which is invalid. This fix adjusts `bufused` when the buffer is written to for the `dirent` so that name truncation happens as expected. Fixes bytecodealliance#2618.
- Loading branch information