Commit 0397af1
committed
Remove unsafe from proto::h2
Back in #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/313831 parent faf24c6 commit 0397af1
3 files changed
+13
-45
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
341 | 341 | | |
342 | 342 | | |
343 | 343 | | |
344 | | - | |
| 344 | + | |
345 | 345 | | |
346 | 346 | | |
347 | 347 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| |||
409 | 408 | | |
410 | 409 | | |
411 | 410 | | |
412 | | - | |
| 411 | + | |
413 | 412 | | |
414 | 413 | | |
415 | 414 | | |
416 | 415 | | |
417 | 416 | | |
418 | | - | |
419 | | - | |
420 | | - | |
| 417 | + | |
| 418 | + | |
421 | 419 | | |
422 | 420 | | |
423 | 421 | | |
424 | | - | |
| 422 | + | |
425 | 423 | | |
426 | 424 | | |
427 | 425 | | |
428 | | - | |
| 426 | + | |
429 | 427 | | |
430 | 428 | | |
431 | 429 | | |
432 | | - | |
| 430 | + | |
433 | 431 | | |
434 | 432 | | |
435 | 433 | | |
436 | 434 | | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
470 | 438 | | |
471 | 439 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
433 | 433 | | |
434 | 434 | | |
435 | 435 | | |
436 | | - | |
| 436 | + | |
437 | 437 | | |
438 | 438 | | |
439 | 439 | | |
| |||
489 | 489 | | |
490 | 490 | | |
491 | 491 | | |
492 | | - | |
| 492 | + | |
493 | 493 | | |
494 | 494 | | |
495 | 495 | | |
| |||
527 | 527 | | |
528 | 528 | | |
529 | 529 | | |
530 | | - | |
| 530 | + | |
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
| |||
0 commit comments