Skip to content

RecvMsg.cmsg() should check MSG_CTRUNC #2400

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

Closed
agrover opened this issue May 10, 2024 · 2 comments · Fixed by #2413
Closed

RecvMsg.cmsg() should check MSG_CTRUNC #2400

agrover opened this issue May 10, 2024 · 2 comments · Fixed by #2413

Comments

@agrover
Copy link
Contributor

agrover commented May 10, 2024

If the cmsg buffer is too small, MSG_CTRUNC will be set in the header flags. This should be checked before returning CmsgIterator, or else the iterator might return invalid data.

@SteveLauC
Copy link
Member

Hi, that indeed should be checked, do you have a good interface for this change in mind?

@agrover
Copy link
Contributor Author

agrover commented May 20, 2024

Hi, that indeed should be checked, do you have a good interface for this change in mind?

I think the simplest thing, although an API change, would be to change RecvMsg::cmsgs() to return a Result<CmsgIterator> instead of a CmsgIterator, and return an error if MSG_CTRUNC was set.

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 a pull request may close this issue.

2 participants