From c60709a58c9154a405141045f74626b25264b3dc Mon Sep 17 00:00:00 2001 From: Burkov Egor Date: Tue, 29 Jul 2025 13:18:48 +0300 Subject: [PATCH] fix: rx operators better null checks --- src/operators/rx.cc | 23 ++++++++++++----------- src/operators/rx_global.cc | 22 ++++++++++++---------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/operators/rx.cc b/src/operators/rx.cc index ce6526356f..de1428e2e5 100644 --- a/src/operators/rx.cc +++ b/src/operators/rx.cc @@ -68,19 +68,20 @@ bool Rx::evaluate(Transaction *transaction, RuleWithActions *rule, // FIXME: DRY regex error reporting. This logic is currently duplicated in other operators. if (regex_result != Utils::RegexResult::Ok) { - transaction->m_variableMscPcreError.set("1", transaction->m_variableOffset); - - std::string regex_error_str = "OTHER"; - if (regex_result == Utils::RegexResult::ErrorMatchLimit) { - regex_error_str = "MATCH_LIMIT"; - transaction->m_variableMscPcreLimitsExceeded.set("1", transaction->m_variableOffset); - transaction->m_collections.m_tx_collection->storeOrUpdateFirst("MSC_PCRE_LIMITS_EXCEEDED", "1"); - ms_dbg_a(transaction, 7, "Set TX.MSC_PCRE_LIMITS_EXCEEDED to 1"); + if (transaction) { + transaction->m_variableMscPcreError.set("1", transaction->m_variableOffset); + + std::string regex_error_str = "OTHER"; + if (regex_result == Utils::RegexResult::ErrorMatchLimit) { + regex_error_str = "MATCH_LIMIT"; + transaction->m_variableMscPcreLimitsExceeded.set("1", transaction->m_variableOffset); + transaction->m_collections.m_tx_collection->storeOrUpdateFirst("MSC_PCRE_LIMITS_EXCEEDED", "1"); + ms_dbg_a(transaction, 7, "Set TX.MSC_PCRE_LIMITS_EXCEEDED to 1"); + } + + ms_dbg_a(transaction, 1, "rx: regex error '" + regex_error_str + "' for pattern '" + re->pattern + "'"); } - ms_dbg_a(transaction, 1, "rx: regex error '" + regex_error_str + "' for pattern '" + re->pattern + "'"); - - return false; } diff --git a/src/operators/rx_global.cc b/src/operators/rx_global.cc index 6aeda76132..a966ed35b3 100644 --- a/src/operators/rx_global.cc +++ b/src/operators/rx_global.cc @@ -62,18 +62,20 @@ bool RxGlobal::evaluate(Transaction *transaction, RuleWithActions *rule, // FIXME: DRY regex error reporting. This logic is currently duplicated in other operators. if (regex_result != Utils::RegexResult::Ok) { - transaction->m_variableMscPcreError.set("1", transaction->m_variableOffset); - - std::string regex_error_str = "OTHER"; - if (regex_result == Utils::RegexResult::ErrorMatchLimit) { - regex_error_str = "MATCH_LIMIT"; - transaction->m_variableMscPcreLimitsExceeded.set("1", transaction->m_variableOffset); - transaction->m_collections.m_tx_collection->storeOrUpdateFirst("MSC_PCRE_LIMITS_EXCEEDED", "1"); - ms_dbg_a(transaction, 7, "Set TX.MSC_PCRE_LIMITS_EXCEEDED to 1"); + if (transaction) { + transaction->m_variableMscPcreError.set("1", transaction->m_variableOffset); + + std::string regex_error_str = "OTHER"; + if (regex_result == Utils::RegexResult::ErrorMatchLimit) { + regex_error_str = "MATCH_LIMIT"; + transaction->m_variableMscPcreLimitsExceeded.set("1", transaction->m_variableOffset); + transaction->m_collections.m_tx_collection->storeOrUpdateFirst("MSC_PCRE_LIMITS_EXCEEDED", "1"); + ms_dbg_a(transaction, 7, "Set TX.MSC_PCRE_LIMITS_EXCEEDED to 1"); + } + + ms_dbg_a(transaction, 1, "rxGlobal: regex error '" + regex_error_str + "' for pattern '" + re->pattern + "'"); } - ms_dbg_a(transaction, 1, "rxGlobal: regex error '" + regex_error_str + "' for pattern '" + re->pattern + "'"); - return false; }