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

return RecvError::Truncated when calling recv_slice with a small buffer #859

Merged
merged 1 commit into from
Nov 27, 2023

Commits on Nov 27, 2023

  1. fix(socket): truncation when calling recv_slice

    When calling `recv_slice`/`peek_slice` in the udp, icmp and raw
    sockets, data is lost when the provided buffer is smaller than the
    payload to be copied (not the case for `peek_slice` because it is not
    dequeued).
    
    With this commit, an `RecvError::Truncated` error is returned. In case
    of UDP, the endpoint is also returned in the error. In case of ICMP, the
    IP address is also returned in the error.
    
    I implemented it the way Whitequark proposes it. Data is still lost, but
    at least the caller knows that the data was truncated to the size of the
    provided buffer. As Whitequark says, it is preferred to call `recv`
    instead of `recv_slice` as there would be no truncation.
    thvdveld committed Nov 27, 2023
    Configuration menu
    Copy the full SHA
    1386417 View commit details
    Browse the repository at this point in the history