nix-rust / nix

Rust friendly bindings to *nix APIs
MIT License
2.57k stars 650 forks source link

recvmsg: Check if CMSG buffer was too small and return an error #2413

Closed agrover closed 1 month ago

agrover commented 1 month ago

If MSG_CTRUNC is set, it is not safe to iterate the cmsgs, since they could have been truncated. Change RecvMsg::cmsgs() to return a Result, and to check for this flag (an API change).

Update tests for API change. Add test for too-small buffer.

fixes #2400

Checklist:

agrover commented 1 month ago

Proposed fix accepted and squashed. Took a swag at updating docstring to mention the new error condition.