From: Ashutosh Gupta (ashugup3) Date: Thu, 22 May 2025 08:14:38 +0000 (+0000) Subject: Pull request #4756: file_api: introduced atomicity for is_file_service_enabled X-Git-Tag: 3.8.1.0~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a39db5918a2056f4de744b7808b0fc6e2b824bbb;p=thirdparty%2Fsnort3.git Pull request #4756: file_api: introduced atomicity for is_file_service_enabled Merge in SNORT/snort3 from ~ASHUGUP3/snort3:bug_CSCwn79296 to master Squashed commit of the following: commit e3162b2fbcb9f865c9a423e0aa4a1ff22892b12e Author: ashutosh Date: Thu May 22 10:42:28 2025 +0530 file_api: introduced atomicity for is_file_service_enabled --- diff --git a/src/file_api/file_service.cc b/src/file_api/file_service.cc index 99ca9d8d8..8860575b8 100644 --- a/src/file_api/file_service.cc +++ b/src/file_api/file_service.cc @@ -41,7 +41,7 @@ using namespace snort; -bool FileService::file_type_id_enabled = false; +std::atomic FileService::file_type_id_enabled(false); bool FileService::file_signature_enabled = false; bool FileService::file_capture_enabled = false; bool FileService::file_processing_initiated = false; @@ -127,7 +127,7 @@ void FileService::thread_term() void FileService::enable_file_type() { - file_type_id_enabled = true; + file_type_id_enabled.store(true, std::memory_order_relaxed); } void FileService::enable_file_signature() @@ -144,7 +144,7 @@ void FileService::enable_file_capture() bool FileService::is_file_service_enabled() { - return (file_type_id_enabled or file_signature_enabled); + return (file_type_id_enabled.load() or file_signature_enabled); } /* Get maximal file depth based on configuration @@ -170,7 +170,7 @@ void FileService::set_max_file_depth(const SnortConfig* sc) if (!file_config) return; - if (file_type_id_enabled) + if (file_type_id_enabled.load()) { file_config->file_depth = file_config->file_type_depth; } diff --git a/src/file_api/file_service.h b/src/file_api/file_service.h index 52ce4cae0..aa99307bc 100644 --- a/src/file_api/file_service.h +++ b/src/file_api/file_service.h @@ -55,7 +55,7 @@ public: static void enable_file_type(); static void enable_file_signature(); static void enable_file_capture(); - static bool is_file_type_id_enabled() { return file_type_id_enabled; } + static bool is_file_type_id_enabled() { return file_type_id_enabled.load(); } static bool is_file_signature_enabled() { return file_signature_enabled; } static bool is_file_capture_enabled() { return file_capture_enabled; } static bool is_file_service_enabled(); @@ -66,7 +66,7 @@ public: static DecodeConfig decode_conf; private: - static bool file_type_id_enabled; + static std::atomic file_type_id_enabled; static bool file_signature_enabled; static bool file_capture_enabled; static bool file_processing_initiated;