nix-rust / nix

Rust friendly bindings to *nix APIs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RecvMsg.cmsg() should check MSG_CTRUNC

agrover opened this issue · comments

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.

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

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.