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

Fix recv_uninit to handle the TRUNC flag. #1159

Merged
merged 2 commits into from
Sep 11, 2024
Merged

Conversation

sunfishcode
Copy link
Member

With the TRUNC flag, recv returns the untruncated length, which may be longer than the provided buffer. Fix recv_uninit and recvfrom_uninit to handle this case.

This mean that recv_uninit and recvfrom_uninit are unable to return the full untruncated length returned by recv with the TRUNC flag, however it appears that fixing that may require API changes.

Fixes #1153.

With the `TRUNC` flag, `recv` returns the untruncated length, which may
be longer than the provided buffer. Fix `recv_uninit` and
`recvfrom_uninit` to handle this case.

This mean that `recv_uninit` and `recvfrom_uninit` are unable to return
the full untruncated length returned by `recv` with the `TRUNC` flag,
however it appears that fixing that may require API changes.

Fixes #1153.
@sunfishcode sunfishcode merged commit fbb0609 into main Sep 11, 2024
43 checks passed
@sunfishcode sunfishcode deleted the sunfishcode/recv-trunc branch September 11, 2024 15:24
@andylizi
Copy link

andylizi commented Sep 11, 2024

While recvfrom indeed works, would this be a good candidate for #753?

UDP socket buffers are often quite large, and their recommended size can even reach multiple megabytes (as seen in quic-go, for example). Not having to zero-initialize all of that seems especially desirable.

sunfishcode added a commit that referenced this pull request Sep 11, 2024
* Fix `recv_uninit` to handle the `TRUNC` flag.

With the `TRUNC` flag, `recv` returns the untruncated length, which may
be longer than the provided buffer. Fix `recv_uninit` and
`recvfrom_uninit` to handle this case.

This mean that `recv_uninit` and `recvfrom_uninit` are unable to return
the full untruncated length returned by `recv` with the `TRUNC` flag,
however it appears that fixing that may require API changes.

Fixes #1153.

* Add comments mentioning alternatives.
sunfishcode added a commit that referenced this pull request Sep 11, 2024
* Fix `recv_uninit` to handle the `TRUNC` flag.

With the `TRUNC` flag, `recv` returns the untruncated length, which may
be longer than the provided buffer. Fix `recv_uninit` and
`recvfrom_uninit` to handle this case.

This mean that `recv_uninit` and `recvfrom_uninit` are unable to return
the full untruncated length returned by `recv` with the `TRUNC` flag,
however it appears that fixing that may require API changes.

Fixes #1153.

* Add comments mentioning alternatives.
@sunfishcode sunfishcode mentioned this pull request Sep 11, 2024
28 tasks
@sunfishcode
Copy link
Member Author

This is now released in rustix 0.38.37.

@andylizi Sounds good, I've now added a todo box to #753 for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

recvmsg_uninit does not work with MSG_TRUNC
2 participants