From 76415440d698df4401b848f22caad21d5fd5b6e3 Mon Sep 17 00:00:00 2001 From: "Victor M. Alvarez" Date: Wed, 6 Sep 2023 10:03:48 +0200 Subject: [PATCH] fix: possible out of bounds slice access --- yara-x/src/re/fast/fastvm.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/yara-x/src/re/fast/fastvm.rs b/yara-x/src/re/fast/fastvm.rs index 27790ecc7..19a7a0a4e 100644 --- a/yara-x/src/re/fast/fastvm.rs +++ b/yara-x/src/re/fast/fastvm.rs @@ -217,9 +217,11 @@ impl<'r> FastVM<'r> { for position in &self.positions { let jump_range = *position..*position + step * jump as usize; - if memchr::memchr(0x0A, &input[jump_range]).is_none() { - next_positions - .insert(position + step * jump as usize); + if let Some(jump_range) = input.get(jump_range) { + if memchr::memchr(0x0A, jump_range).is_none() { + next_positions + .insert(position + step * jump as usize); + } } } }