From: Oleg Torubara -X (otorubar - SOFTSERVE INC at Cisco) Date: Thu, 14 Nov 2024 19:47:09 +0000 (+0000) Subject: Pull request #4515: file_api: add helper methods to unset a FileInfo::is_filename_set... X-Git-Tag: 3.5.2.0~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8cdf2911f77f3501984efdf1d1340585a867c6b2;p=thirdparty%2Fsnort3.git Pull request #4515: file_api: add helper methods to unset a FileInfo::is_filename_set flag and reset FileInfo::sha256 for file re-evaluation Merge in SNORT/snort3 from ~OTORUBAR/snort3:file_cache_fix to master Squashed commit of the following: commit b3d0034c497eab42dd06bcb41f2746f7357e937f Author: otorubar Date: Thu Nov 7 13:59:03 2024 -0800 file_api: add helper methods to unset filename and reset sha --- diff --git a/src/file_api/file_flows.cc b/src/file_api/file_flows.cc index c00610180..8ea2935aa 100644 --- a/src/file_api/file_flows.cc +++ b/src/file_api/file_flows.cc @@ -101,7 +101,8 @@ void FileFlows::handle_retransmit(Packet* p) bool is_new_context = false; FileContext* file = get_file_context(pending_file_id, false, is_new_context); - if ((file == nullptr) or (file->verdict != FILE_VERDICT_PENDING)) + if ((file == nullptr) or + ((file->verdict != FILE_VERDICT_PENDING) and (file->is_cacheable()))) { FILE_DEBUG(file_trace, DEFAULT_TRACE_OPTION_ID, TRACE_ERROR_LEVEL, p, "handle_retransmit:context is null or verdict not pending, returning\n"); diff --git a/src/file_api/file_lib.cc b/src/file_api/file_lib.cc index 3799e665c..71287405f 100644 --- a/src/file_api/file_lib.cc +++ b/src/file_api/file_lib.cc @@ -177,6 +177,21 @@ void FileInfo::set_weak_file_name(const char* name, uint32_t name_size) file_name.assign(name, name_size); } +void FileInfo::unset_file_name() +{ + file_name_set = false; +} + + void FileInfo::reset_sha() + { + if (sha256) + { + delete [] sha256; + sha256 = nullptr; + file_state.sig_state = FILE_SIG_PROCESSING; + } + } + void FileInfo::set_url(const char* url_name, uint32_t url_size) { if (url_name and url_size) diff --git a/src/file_api/file_lib.h b/src/file_api/file_lib.h index 900625e8a..08cb0f93d 100644 --- a/src/file_api/file_lib.h +++ b/src/file_api/file_lib.h @@ -66,6 +66,8 @@ public: const std::string& get_url() const; const std::string& get_host_name() const; + void unset_file_name(); + void reset_sha(); // Whether file name has been set (could be empty file name) bool is_file_name_set() const { return file_name_set; } bool is_url_set() const { return url_set; }