]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #4274: Porting into 7.7(master) release for CSCwh30257(snort3)
authorSumit Kumar (sumikum7) <sumikum7@cisco.com>
Wed, 17 Apr 2024 07:15:53 +0000 (07:15 +0000)
committerBhargava Jandhyala (bjandhya) <bjandhya@cisco.com>
Wed, 17 Apr 2024 07:15:53 +0000 (07:15 +0000)
Merge in SNORT/snort3 from ~SUMIKUM7/snort3:77_release to master

Squashed commit of the following:

commit 264970ec565d5ab79d186865b11f59faaed5653c
Author: Sumit Kumar <sumikum7@cisco.com>
Date:   Wed Apr 10 12:38:00 2024 +0530

    file_api: porting fixes of two crashes in file inspector in master(77 release)

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

index 04ee6a65eeffae3a00e4cfed7a142ffb2148258f..c37e0e08f3370fd51925042b38dca338b0c22a72 100644 (file)
@@ -333,23 +333,6 @@ void FileFlows::remove_processed_file_context(uint64_t file_id)
         current_context_delete_pending = true;
 }
 
-// Remove file context explicitly
-void FileFlows::remove_processed_file_context(uint64_t file_id, uint64_t multi_file_processing_id)
-{
-    bool is_new_context = false;
-
-    if (!multi_file_processing_id)
-        multi_file_processing_id = file_id;
-
-    FileContext* context = get_file_context(file_id, false, is_new_context, multi_file_processing_id);
-    if (context)
-    {
-        set_current_file_context(context);
-        context->processing_complete = true;
-        remove_processed_file_context(multi_file_processing_id);
-    }
-}
-
 /* This function is used to process file that is sent in pieces
  *
  * Return:
@@ -390,7 +373,10 @@ bool FileFlows::file_process(Packet* p, uint64_t file_id, const uint8_t* file_da
     if (!cacheable)
         context->set_not_cacheable();
 
-    set_current_file_context(context);
+    if(!context->processing_complete)
+        set_current_file_context(context);
+    else
+        current_file_id = file_id;
 
     // Only increase file count when there are no queued segments
     // This will ensure we only count a file once in case it has
index 21446a45d111d191e764e6613716061fcef1776d..abd6ad13a31bbad38cee9518f80a1bda904a0f04 100644 (file)
@@ -78,8 +78,6 @@ public:
     // Remove a file from the flow object when processing is complete
     void remove_processed_file_context(uint64_t file_id);
 
-    void remove_processed_file_context(uint64_t file_id, uint64_t multi_file_processing_id);
-
     uint64_t get_new_file_instance();
 
     bool set_file_name(const uint8_t* fname, uint32_t name_size, uint64_t file_id=0,
index 2c2f402ce9d643bcf454f6771bfb2023d6742934..aca3b17c71c3bb2d8b9be592c40d19949962d2df 100644 (file)
@@ -641,7 +641,8 @@ void FileContext::find_file_type_from_ips(Packet* pkt, const uint8_t* file_data,
     if ((int64_t)processed_bytes + data_size >= config->file_type_depth)
     {
         data_size = config->file_type_depth - processed_bytes;
-        assert(data_size > 0);
+        if (data_size < 0)
+               return;
         depth_exhausted = true;
     }
     const FileConfig* const conf = get_file_config();
@@ -679,7 +680,8 @@ void FileContext::process_file_type(Packet* pkt,const uint8_t* file_data, int da
     FilePosition position)
 {
     /* file type already found and no magics to continue */
-    find_file_type_from_ips(pkt, file_data, data_size, position);
+    if (SNORT_FILE_TYPE_CONTINUE == file_type_id)
+        find_file_type_from_ips(pkt, file_data, data_size, position);
 }
 
 void FileContext::process_file_signature_sha256(const uint8_t* file_data, int data_size,