WebAssembly / WASI

WebAssembly System Interface
Other
4.84k stars 251 forks source link

Document behaviour of path_readlink when buf is too small #554

Closed zoraaver closed 1 year ago

zoraaver commented 1 year ago

readlink and readlinkat in POSIX specify that if the buffer is too small to contain the link content, the first buf_len bytes will be written. We already state the behaviour of this function is similar to readlinkat but explicitly clarifying this case removes any ambiguity.

I ran into this issue when fixing the WASI tests for WAMR. Alternatively, if we don't want to enforce this behaviour, I can modify the PR to state the behaviour is undefined when the buffer is too small (currently wasmtime returns an error in this case). Given the current docs mention readlinkat, I think it's reasonable to assume the behaviour is the same unless specified otherwise.

Please let me know if there any other concerns or suggestions.

pchickey commented 1 year ago

Thanks, this is always been a nasty corner case. (One I am happy we fixed in preview 2!)