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

Remove unsafe from proto::h2 #2831

Closed
wants to merge 1 commit into from
Closed

Remove unsafe from proto::h2 #2831

wants to merge 1 commit into from

Commits on May 10, 2022

  1. fix(http2): Remove unsafe from proto::h2

    Back in hyperium#2523, @nox introduced the notion of an UpgradedSendStream, to
    support the CONNECT method of HTTP/2. This used `unsafe {}` to support
    `http_body::Body`, where `Body::Data` did not implement `Send`, since
    the `Data` type wouldn't be sent across the stream once upgraded.
    
    Unfortunately, according to this [thread], I think this may be undefined
    behavior, because this relies on us requiring the transmute to execute.
    
    This patch fixes the potential UB by adding the unncessary `Send`
    constraints. It appears that all the internal users of
    `UpgradeSendStream` already work with `http_body::Body` types that have
    `Send`-able `Data` constraints. We can add this constraint without
    breaking any external APIs, which lets us remove the `unsafe {}` blocks.
    
    [thread]: https://users.rust-lang.org/t/is-a-reference-to-impossible-value-considered-ub/31383
    erickt committed May 10, 2022
    Configuration menu
    Copy the full SHA
    0bd9d16 View commit details
    Browse the repository at this point in the history