]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
minor mime log cleanup
authorhuica <huica@cisco.com>
Fri, 24 Jul 2015 14:35:59 +0000 (10:35 -0400)
committerhuica <huica@cisco.com>
Fri, 24 Jul 2015 14:35:59 +0000 (10:35 -0400)
src/file_api/file_mime_log.cc
src/file_api/file_mime_log.h

index 7c8cf97c80594c337cbd3916cae8d01955e36ec5..48a2109629e54d618017feb753e8fe66d35e30d4 100644 (file)
@@ -136,9 +136,9 @@ int MailLogState::log_file_name(const uint8_t* start, int length, bool* disp_con
 
     length = ret;
 
-    alt_buf = log_state.filenames;
+    alt_buf = filenames;
     alt_size =  MAX_FILE;
-    alt_len = &(log_state.file_logged);
+    alt_len = &(file_logged);
     log_avail = alt_size - *alt_len;
 
     if (!alt_buf || (log_avail <= 0))
@@ -162,7 +162,7 @@ int MailLogState::log_file_name(const uint8_t* start, int length, bool* disp_con
         return -1;
     }
 
-    log_state.file_current = *alt_len;
+    file_current = *alt_len;
     *alt_len += length;
 
     log_flags |= MIME_FLAG_FILENAME_PRESENT;
@@ -175,10 +175,10 @@ void MailLogState::set_file_name_from_log(void* pv)
 {
     Flow* ssn = (Flow*)pv; // FIXIT-M eliminate need for cast
 
-    if (log_state.file_logged > log_state.file_current)
+    if (file_logged > file_current)
     {
-        file_api->set_file_name(ssn, log_state.filenames + log_state.file_current,
-            log_state.file_logged -log_state.file_current);
+        file_api->set_file_name(ssn, filenames + file_current,
+            file_logged - file_current);
     }
     else
     {
@@ -304,8 +304,8 @@ int MailLogState::log_email_id(const uint8_t* start, int length, EmailUserType t
 
 void MailLogState::get_file_name(uint8_t** buf, uint32_t* len)
 {
-    *buf = log_state.filenames;
-    *len = log_state.file_logged;
+    *buf = filenames;
+    *len = file_logged;
 }
 
 void MailLogState::get_email_hdrs(uint8_t** buf, uint32_t* len)
@@ -369,16 +369,18 @@ MailLogState::MailLogState(MailLogConfig* conf)
         {
             log_depth = conf->email_hdrs_log_depth;
             recipients = buf;
-            rcpts_logged = 0;
             senders = buf + MAX_EMAIL;
-            snds_logged = 0;
-            log_state.filenames = buf + (2*MAX_EMAIL);
-            log_state.file_logged = 0;
-            log_state.file_current = 0;
+            filenames = buf + (2*MAX_EMAIL);
             emailHdrs = buf + (2*MAX_EMAIL) + MAX_FILE;
-            hdrs_logged = 0;
+
         }
     }
+
+    rcpts_logged = 0;
+    snds_logged = 0;
+    file_logged = 0;
+    file_current = 0;
+    hdrs_logged = 0;
 }
 
 MailLogState::~MailLogState()
index bac55c93c84e54cfc4947233dceed21fd50afb34..2b44f5ef8c6e3d4bc389089e62a83d00eda1b675 100644 (file)
@@ -35,13 +35,6 @@ enum EmailUserType
     EMAIL_RECIPIENT
 };
 
-struct FileLogState
-{
-    uint8_t* filenames;
-    uint16_t file_logged;
-    uint16_t file_current;
-};
-
 class MailLogState
 {
 public:
@@ -62,16 +55,18 @@ public:
 
 private:
     int extract_file_name(const char** start, int length, bool* disp_cont);
-    FileLogState log_state;
     int log_flags = 0;
     uint8_t* buf = NULL;
     unsigned char* emailHdrs;
     uint32_t log_depth;
     uint32_t hdrs_logged;
-    uint8_t* recipients;
+    uint8_t* recipients = NULL;
     uint16_t rcpts_logged;
-    uint8_t* senders;
+    uint8_t* senders = NULL;
     uint16_t snds_logged;
+    uint8_t* filenames = NULL;
+    uint16_t file_logged;
+    uint16_t file_current;
 };
 
 struct MailLogConfig