Skip to content
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

wasi-common: change behavior of path_readlink to truncate on too-small buffer #6225

Merged
merged 1 commit into from
Apr 18, 2023

Conversation

pchickey
Copy link
Contributor

This is the same behavior on a too-small buffer as posix readlink(2).

The correct way to call readlink(2), and therefore path_readlink, is to call it multiple times with incrementally larger buffers until the bytes returned is smaller than the buffer passed in, to ensure the value is not being truncated. Userlands are used to this restriction.

Thankfully this nonsense goes away, thanks to the component model, in preview 2, where path_readlink just gives a string. Only the (host) component interfacing with a posix readlink(2) needs to do the truncation detection dance.

…l buffers

this is the same behavior as exists in posix readlink(2)
@pchickey pchickey requested a review from a team as a code owner April 17, 2023 22:08
@pchickey pchickey requested review from alexcrichton and sunfishcode and removed request for a team April 17, 2023 22:08
pchickey pushed a commit to bytecodealliance/preview2-prototyping that referenced this pull request Apr 17, 2023
@github-actions github-actions bot added the wasi Issues pertaining to WASI label Apr 18, 2023
@github-actions
Copy link

Subscribe to Label Action

cc @kubkon

This issue or pull request has been labeled: "wasi"

Thus the following users have been cc'd because of the following labels:

  • kubkon: wasi

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

@pchickey pchickey added this pull request to the merge queue Apr 18, 2023
Merged via the queue into main with commit 24b607c Apr 18, 2023
@pchickey pchickey deleted the pch/path_readlink_truncation branch April 18, 2023 18:47
eduardomourar pushed a commit to eduardomourar/wasmtime that referenced this pull request Apr 28, 2023
…l buffers (bytecodealliance#6225)

this is the same behavior as exists in posix readlink(2)
pchickey pushed a commit to pchickey/wasmtime that referenced this pull request May 12, 2023
pchickey pushed a commit to pchickey/wasmtime that referenced this pull request May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasi Issues pertaining to WASI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants