]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #4515: file_api: add helper methods to unset a FileInfo::is_filename_set...
authorOleg Torubara -X (otorubar - SOFTSERVE INC at Cisco) <otorubar@cisco.com>
Thu, 14 Nov 2024 19:47:09 +0000 (19:47 +0000)
committerSteve Chew (stechew) <stechew@cisco.com>
Thu, 14 Nov 2024 19:47:09 +0000 (19:47 +0000)
Merge in SNORT/snort3 from ~OTORUBAR/snort3:file_cache_fix to master

Squashed commit of the following:

commit b3d0034c497eab42dd06bcb41f2746f7357e937f
Author: otorubar <otorubar@cisco.com>
Date:   Thu Nov 7 13:59:03 2024 -0800

    file_api: add helper methods to unset filename and reset sha

src/file_api/file_flows.cc
src/file_api/file_lib.cc
src/file_api/file_lib.h

index c00610180496bf1f50b734422e0c133434b0b2fa..8ea2935aa2d55b3a6e771452262b39d1b6834d7b 100644 (file)
@@ -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");
index 3799e665c3a8f380d0c54ed0e9bd25404c9f0873..71287405fc529801b7d57ff7765976aa1ece7314 100644 (file)
@@ -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)
index 900625e8a8ea8018f94e9150c3444cf0c0e335a6..08cb0f93d4114958a9c532c4be5efdb842b45cee 100644 (file)
@@ -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; }