diff --git a/h3/src/qpack/block.rs b/h3/src/qpack/block.rs index d674a534..1ba16306 100644 --- a/h3/src/qpack/block.rs +++ b/h3/src/qpack/block.rs @@ -179,11 +179,15 @@ impl HeaderPrefix { let (sign_negative, delta_base) = prefix_int::decode(7, buf)?; if encoded_insert_count > (usize::MAX as u64) { - return Err(ParseError::Integer(crate::qpack::prefix_int::Error::Overflow)) + return Err(ParseError::Integer( + crate::qpack::prefix_int::Error::Overflow, + )); } if delta_base > (usize::MAX as u64) { - return Err(ParseError::Integer(crate::qpack::prefix_int::Error::Overflow)) + return Err(ParseError::Integer( + crate::qpack::prefix_int::Error::Overflow, + )); } Ok(Self { @@ -211,18 +215,22 @@ impl Indexed { match prefix_int::decode(6, buf)? { (0b11, i) => { if i > (usize::MAX as u64) { - return Err(ParseError::Integer(crate::qpack::prefix_int::Error::Overflow)) + return Err(ParseError::Integer( + crate::qpack::prefix_int::Error::Overflow, + )); } Ok(Indexed::Static(i as usize)) - }, + } (0b10, i) => { if i > (usize::MAX as u64) { - return Err(ParseError::Integer(crate::qpack::prefix_int::Error::Overflow)) + return Err(ParseError::Integer( + crate::qpack::prefix_int::Error::Overflow, + )); } Ok(Indexed::Dynamic(i as usize)) - }, + } (f, _) => Err(ParseError::InvalidPrefix(f)), } } @@ -243,11 +251,13 @@ impl IndexedWithPostBase { match prefix_int::decode(4, buf)? { (0b0001, i) => { if i > (usize::MAX as u64) { - return Err(ParseError::Integer(crate::qpack::prefix_int::Error::Overflow)) + return Err(ParseError::Integer( + crate::qpack::prefix_int::Error::Overflow, + )); } Ok(IndexedWithPostBase(i as usize)) - }, + } (f, _) => Err(ParseError::InvalidPrefix(f)), } } @@ -282,22 +292,28 @@ impl LiteralWithNameRef { match prefix_int::decode(4, buf)? { (f, i) if f & 0b0101 == 0b0101 => { if i > (usize::MAX as u64) { - return Err(ParseError::Integer(crate::qpack::prefix_int::Error::Overflow)) + return Err(ParseError::Integer( + crate::qpack::prefix_int::Error::Overflow, + )); } Ok(LiteralWithNameRef::new_static( - i as usize, - prefix_string::decode(8, buf)?)) - }, + i as usize, + prefix_string::decode(8, buf)?, + )) + } (f, i) if f & 0b0101 == 0b0100 => { if i > (usize::MAX as u64) { - return Err(ParseError::Integer(crate::qpack::prefix_int::Error::Overflow)) + return Err(ParseError::Integer( + crate::qpack::prefix_int::Error::Overflow, + )); } Ok(LiteralWithNameRef::new_dynamic( - i as usize, - prefix_string::decode(8, buf)?)) - }, + i as usize, + prefix_string::decode(8, buf)?, + )) + } (f, _) => Err(ParseError::InvalidPrefix(f)), } } @@ -335,13 +351,16 @@ impl LiteralWithPostBaseNameRef { match prefix_int::decode(3, buf)? { (f, i) if f & 0b1111_0000 == 0 => { if i > (usize::MAX as u64) { - return Err(ParseError::Integer(crate::qpack::prefix_int::Error::Overflow)) + return Err(ParseError::Integer( + crate::qpack::prefix_int::Error::Overflow, + )); } Ok(LiteralWithPostBaseNameRef::new( - i as usize, - prefix_string::decode(8, buf)?)) - }, + i as usize, + prefix_string::decode(8, buf)?, + )) + } (f, _) => Err(ParseError::InvalidPrefix(f)), } } diff --git a/h3/src/qpack/decoder.rs b/h3/src/qpack/decoder.rs index 06309c9b..799002bc 100644 --- a/h3/src/qpack/decoder.rs +++ b/h3/src/qpack/decoder.rs @@ -128,7 +128,8 @@ impl Decoder { } if self.table.total_inserted() != inserted_on_start { - InsertCountIncrement((self.table.total_inserted() - inserted_on_start).try_into()?).encode(write); + InsertCountIncrement((self.table.total_inserted() - inserted_on_start).try_into()?) + .encode(write); } Ok(self.table.total_inserted()) diff --git a/h3/src/qpack/encoder.rs b/h3/src/qpack/encoder.rs index 7af19847..567b685d 100644 --- a/h3/src/qpack/encoder.rs +++ b/h3/src/qpack/encoder.rs @@ -239,9 +239,8 @@ impl Action { let first = buf.chunk()[0]; let instruction = match DecoderInstruction::decode(first) { DecoderInstruction::Unknown => return Err(Error::UnknownDecoderInstruction(first)), - DecoderInstruction::InsertCountIncrement => { - InsertCountIncrement::decode(&mut buf)?.map(|x| Action::ReceivedRefIncrement(x.0 as usize)) - } + DecoderInstruction::InsertCountIncrement => InsertCountIncrement::decode(&mut buf)? + .map(|x| Action::ReceivedRefIncrement(x.0 as usize)), DecoderInstruction::HeaderAck => { HeaderAck::decode(&mut buf)?.map(|x| Action::Untrack(x.0)) } diff --git a/h3/src/qpack/stream.rs b/h3/src/qpack/stream.rs index b6897b83..792fbf9c 100644 --- a/h3/src/qpack/stream.rs +++ b/h3/src/qpack/stream.rs @@ -97,7 +97,9 @@ impl InsertWithNameRef { Err(IntError::UnexpectedEnd) => return Ok(None), Err(e) => return Err(e.into()), }; - let index: usize = index.try_into().map_err(|e| ParseError::Integer(crate::qpack::prefix_int::Error::Overflow))?; + let index: usize = index + .try_into() + .map_err(|e| ParseError::Integer(crate::qpack::prefix_int::Error::Overflow))?; let value = match prefix_string::decode(8, buf) { Ok(x) => x, @@ -170,10 +172,12 @@ impl Duplicate { let index = match prefix_int::decode(5, buf) { Ok((0, x)) => { if x > (usize::MAX as u64) { - return Err(ParseError::Integer(crate::qpack::prefix_int::Error::Overflow)) + return Err(ParseError::Integer( + crate::qpack::prefix_int::Error::Overflow, + )); } x as usize - }, + } Ok((f, _)) => return Err(ParseError::InvalidPrefix(f)), Err(IntError::UnexpectedEnd) => return Ok(None), Err(e) => return Err(e.into()), @@ -194,10 +198,12 @@ impl DynamicTableSizeUpdate { let size = match prefix_int::decode(5, buf) { Ok((0b001, x)) => { if x > (usize::MAX as u64) { - return Err(ParseError::Integer(crate::qpack::prefix_int::Error::Overflow)) + return Err(ParseError::Integer( + crate::qpack::prefix_int::Error::Overflow, + )); } x as usize - }, + } Ok((f, _)) => return Err(ParseError::InvalidPrefix(f)), Err(IntError::UnexpectedEnd) => return Ok(None), Err(e) => return Err(e.into()), @@ -264,10 +270,12 @@ impl InsertCountIncrement { let insert_count = match prefix_int::decode(6, buf) { Ok((0b00, x)) => { if x > 64 { - return Err(ParseError::Integer(crate::qpack::prefix_int::Error::Overflow)) + return Err(ParseError::Integer( + crate::qpack::prefix_int::Error::Overflow, + )); } x as u8 - }, + } Ok((f, _)) => return Err(ParseError::InvalidPrefix(f)), Err(IntError::UnexpectedEnd) => return Ok(None), Err(e) => return Err(e.into()),