-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix fd_readdir
to properly truncate directory entry names.
#2620
Conversation
5b35c73
to
6079d72
Compare
Subscribe to Label Actioncc @kubkon
This issue or pull request has been labeled: "wasi", "wasi:impl"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
This commit removes what appears to be a workaround to the bug being fixed by the change in bytecodealliance#2620.
This commit removes what appears to be a workaround to the bug being fixed by the change in bytecodealliance#2620.
ca81d53
to
9ff8101
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is very confusing and I very much look forwards to re-designing this interface in a future WASI so that none of this nonsense is required. Thank you for the fix!
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.
This commit removes what appears to be a workaround to the bug being fixed by the change in bytecodealliance#2620.
9ff8101
to
0502cad
Compare
This commit removes what appears to be a workaround to the bug being fixed by the change in bytecodealliance#2620.
Previously,
fd_readdir
was truncating directory entry names based on thecalculation of
min(name_len, buf_len - bufused)
, butbufused
was not beingupdated after writing in the
dirent
structure to the buffer.This allowed
bufused
to be incremented beyondbuf_len
and returned as thenumber of bytes written to the buffer, which is invalid.
This fix adjusts
bufused
when the buffer is written to for thedirent
sothat name truncation happens as expected.
Fixes #2618.