]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
smb: fix 'dangling' files in lossy sessions 5138/head
authorVictor Julien <victor@inliniac.net>
Fri, 15 May 2020 07:57:42 +0000 (09:57 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 6 Jul 2020 20:50:05 +0000 (22:50 +0200)
In case of lossy connections the SMB state would properly clean up
transactions, including file transactions. However for files the
state was never set to 'truncated', leading to files to stay 'active'.

This would lead these files staying in the SMB's state. In long running
sessions with lots of files this would lead to performance and memory
use issues.

This patch cleans truncates the file that was being transmitted when
a file transaction is being closed.

rust/src/smb/smb.rs

index 1bff8b2691c3550d380af35ab2473eaaa775f515..d7b71f8fa8fa5abe8c765fb56758c81b3fd6ebf0 100644 (file)
@@ -1160,11 +1160,13 @@ impl SMBState {
     {
         let mut post_gap_txs = false;
         for tx in &mut self.transactions {
-            if let Some(SMBTransactionTypeData::FILE(ref f)) = tx.type_data {
+            if let Some(SMBTransactionTypeData::FILE(ref mut f)) = tx.type_data {
                 if f.post_gap_ts > 0 {
                     if self.ts > f.post_gap_ts {
                         tx.request_done = true;
                         tx.response_done = true;
+                        let (files, flags) = self.files.get(f.direction);
+                        f.file_tracker.trunc(files, flags);
                     } else {
                         post_gap_txs = true;
                     }