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

Check QUIC Bit that Short Header Packet set too #1404

Merged
merged 2 commits into from Sep 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions quinn-proto/src/packet.rs
Expand Up @@ -536,6 +536,9 @@ impl PlainHeader {
grease_quic_bit: bool,
) -> Result<Self, PacketDecodeError> {
let first = buf.get::<u8>()?;
if !grease_quic_bit && first & FIXED_BIT == 0 {
return Err(PacketDecodeError::InvalidHeader("fixed bit unset"));
}
if first & LONG_HEADER_FORM == 0 {
let spin = first & SPIN_BIT != 0;
if buf.remaining() < local_cid_len {
Expand Down Expand Up @@ -572,7 +575,7 @@ impl PlainHeader {
});
}

match LongHeaderType::from_byte(first, grease_quic_bit)? {
match LongHeaderType::from_byte(first)? {
LongHeaderType::Initial => {
let token_len = buf.get_var()? as usize;
let token_start = buf.position() as usize;
Expand Down Expand Up @@ -719,11 +722,8 @@ pub(crate) enum LongHeaderType {
}

impl LongHeaderType {
fn from_byte(b: u8, grease_quic_bit: bool) -> Result<Self, PacketDecodeError> {
fn from_byte(b: u8) -> Result<Self, PacketDecodeError> {
use self::{LongHeaderType::*, LongType::*};
if !grease_quic_bit && b & FIXED_BIT == 0 {
return Err(PacketDecodeError::InvalidHeader("fixed bit unset"));
}
debug_assert!(b & LONG_HEADER_FORM != 0, "not a long packet");
Ok(match (b & 0x30) >> 4 {
0x0 => Initial,
Expand Down