From 0e24d13b8b75c073b4ae23c503f8ee955b1e0ce0 Mon Sep 17 00:00:00 2001 From: mdecimus Date: Fri, 22 Nov 2024 18:22:47 +1300 Subject: [PATCH] Fix register_match_var out of bounds error (closes stalwartlabs/mail-server#941) --- CHANGELOG | 4 ++++ Cargo.toml | 4 ++-- src/compiler/grammar/actions/action_set.rs | 1 + src/compiler/grammar/instruction.rs | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 63e9dc0..b2a0213 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +sieve-rs 0.5.3 +================================ +- Fixed `register_match_var` function. + sieve-rs 0.5.2 ================================ - Fixed `set_global_variable` function. diff --git a/Cargo.toml b/Cargo.toml index 6d0b166..621b039 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ license = "AGPL-3.0-only" keywords = ["sieve", "interpreter", "compiler", "email", "mail"] categories = ["email", "compilers"] readme = "README.md" -version = "0.5.2" +version = "0.5.3" edition = "2021" [lib] @@ -21,7 +21,7 @@ phf = { version = "0.11", features = ["macros"] } serde = { version = "1.0", features = ["derive", "rc"] } bincode = "1.3.3" ahash = { version = "0.8.0" } -fancy-regex = "0.13.0" +fancy-regex = "0.14.0" [dev-dependencies] serde_json = "1.0" diff --git a/src/compiler/grammar/actions/action_set.rs b/src/compiler/grammar/actions/action_set.rs index 1377c4e..b7ff687 100644 --- a/src/compiler/grammar/actions/action_set.rs +++ b/src/compiler/grammar/actions/action_set.rs @@ -36,6 +36,7 @@ use crate::{ }; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[allow(clippy::large_enum_variant)] pub(crate) enum Modifier { Lower, Upper, diff --git a/src/compiler/grammar/instruction.rs b/src/compiler/grammar/instruction.rs index cf3dedc..55d8018 100644 --- a/src/compiler/grammar/instruction.rs +++ b/src/compiler/grammar/instruction.rs @@ -912,7 +912,7 @@ impl<'x> CompilerState<'x> { debug_assert!(num < 63); for pos in &block.match_test_pos { - if let Instruction::Test(test) = &mut self.instructions[*pos] { + if let Some(Instruction::Test(test)) = self.instructions.get_mut(*pos) { let match_type = match test { Test::Address(t) => &mut t.match_type, Test::Body(t) => &mut t.match_type,