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.
readlink
andreadlinkat
in POSIX specify that if the buffer is too small to contain the link content, the firstbuf_len
bytes will be written. We already state the behaviour of this function is similar toreadlinkat
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.