From d4f92bc4305dbed27c41862e40a84ec028367a84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolphe=20Br=C3=A9ard?= Date: Mon, 27 Mar 2023 23:29:53 +0200 Subject: [PATCH] Prevent an eventual out of range index --- src/parsed_message.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/parsed_message.rs b/src/parsed_message.rs index 336234a..20705dc 100644 --- a/src/parsed_message.rs +++ b/src/parsed_message.rs @@ -33,8 +33,8 @@ fn header_end_pos(data: &[u8]) -> Result { .windows(2) .position(|w| w == b"\r\n") .ok_or(())? + 2; - if ret == max_len { - return Ok(ret); + if ret >= max_len { + return Ok(max_len); } if !is_wsp(data[ret]) { return Ok(ret);