From a41766363892fd45c8850e5e6e2f67293ebbe4cb Mon Sep 17 00:00:00 2001 From: caleb Date: Mon, 20 Jun 2022 16:23:29 +0300 Subject: [PATCH] header: Check dht length is correct --- src/headers.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/headers.rs b/src/headers.rs index 4166aa7..0ebb483 100644 --- a/src/headers.rs +++ b/src/headers.rs @@ -110,9 +110,12 @@ where )?); } } - }; - if dht_length > 0 { - return Err(DecodeErrors::HuffmanDecode(format!("Bogus Huffman table definition"))); + } + if dht_length > 0 + { + return Err(DecodeErrors::HuffmanDecode(format!( + "Bogus Huffman table definition" + ))); } Ok(()) } @@ -486,21 +489,22 @@ pub(crate) fn parse_app( where R: BufRead + Read, { - let length = read_u16_be(buf)?.checked_sub(2) + let length = read_u16_be(buf)? + .checked_sub(2) .ok_or(DecodeErrors::Format(format!( "Invalid APP0 length. Length should be greater than 2" )))?; - let mut bytes_read = 0; match marker { Marker::APP(0) => { - if length !=14{ - warn!("Incorrect length of APP0 ,{}, should be 14",length); + if length != 14 + { + warn!("Incorrect length of APP0 ,{}, should be 14", length); } - // Don't handle APP0 as of now + // Don't handle APP0 as of now buf.consume(length as usize); } Marker::APP(1) =>