Fix fd_readdir to properly truncate directory entry names.#2620
Merged
Conversation
5b35c73 to
6079d72
Compare
Subscribe to Label Actioncc @kubkon DetailsThis 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 |
peterhuene
added a commit
to peterhuene/wasmtime
that referenced
this pull request
Jan 28, 2021
This commit removes what appears to be a workaround to the bug being fixed by the change in bytecodealliance#2620.
peterhuene
added a commit
to peterhuene/wasmtime
that referenced
this pull request
Jan 28, 2021
This commit removes what appears to be a workaround to the bug being fixed by the change in bytecodealliance#2620.
ca81d53 to
9ff8101
Compare
pchickey
reviewed
Feb 1, 2021
pchickey
reviewed
Feb 1, 2021
pchickey
approved these changes
Feb 1, 2021
Contributor
pchickey
left a comment
There was a problem hiding this comment.
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!
pchickey
added a commit
that referenced
this pull request
Feb 1, 2021
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
peterhuene
added a commit
to peterhuene/wasmtime
that referenced
this pull request
Feb 4, 2021
This commit removes what appears to be a workaround to the bug being fixed by the change in bytecodealliance#2620.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously,
fd_readdirwas truncating directory entry names based on thecalculation of
min(name_len, buf_len - bufused), butbufusedwas not beingupdated after writing in the
direntstructure to the buffer.This allowed
bufusedto be incremented beyondbuf_lenand returned as thenumber of bytes written to the buffer, which is invalid.
This fix adjusts
bufusedwhen the buffer is written to for thedirentsothat name truncation happens as expected.
Fixes #2618.