]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #5089: mime: fix compile issues
authorAnna Norokh -X (anorokh - SOFTSERVE INC at Cisco) <anorokh@cisco.com>
Tue, 13 Jan 2026 13:13:10 +0000 (13:13 +0000)
committerOleksii Shumeiko -X (oshumeik - SOFTSERVE INC at Cisco) <oshumeik@cisco.com>
Tue, 13 Jan 2026 13:13:10 +0000 (13:13 +0000)
Merge in SNORT/snort3 from ~ANOROKH/snort3:fix_comp_issues_mime to master

Squashed commit of the following:

commit 811fd8cd31e5bc8b84696c420d604568075888b7
Author: anorokh <anorokh@cisco.com>
Date:   Sat Jan 10 17:41:00 2026 +0200

    mime: fix compile issues (one is false positive)

src/mime/file_mime_context_data.cc
src/mime/file_mime_log.cc
src/mime/file_mime_paf.h
src/mime/test/CMakeLists.txt
src/mime/test/file_mime_log_test.cc

index 291f61b9f8d1f246a176679824be4d96effd6d41..12bb2e4a95b0e875494f12a4ca11092233d4034f 100644 (file)
@@ -52,21 +52,21 @@ void MimeDecodeContextData::init()
 
 uint8_t* MimeDecodeContextData::get_decode_buf()
 {
-    MimeDecodeContextData* data = IpsContextData::get<MimeDecodeContextData>(mime_ips_id);
+    const MimeDecodeContextData* data = IpsContextData::get<MimeDecodeContextData>(mime_ips_id);
 
     return data->decode_buf;
 }
 
 uint8_t* MimeDecodeContextData::get_decompress_buf()
 {
-    MimeDecodeContextData* data = IpsContextData::get<MimeDecodeContextData>(mime_ips_id);
+    const MimeDecodeContextData* data = IpsContextData::get<MimeDecodeContextData>(mime_ips_id);
 
     return data->decompress_buf;
 }
 
 uint32_t MimeDecodeContextData::get_decompress_buf_size()
 {
-    MimeDecodeContextData* data = IpsContextData::get<MimeDecodeContextData>(mime_ips_id);
+    const MimeDecodeContextData* data = IpsContextData::get<MimeDecodeContextData>(mime_ips_id);
 
     return data->decompress_buf_size;
 }
index af131b0cb4d5b3e1b6add2353d28239a792d61ca..054d0646bc4c3b2278d3b009e60691be99ee0fa9 100644 (file)
@@ -26,7 +26,6 @@
 
 #include "file_mime_log.h"
 
-#include "file_api/file_flows.h"
 #include "utils/safec.h"
 #include "utils/util.h"
 
@@ -54,7 +53,7 @@ int MailLogState::log_file_name(const uint8_t* start, int length)
     int sep = (*alt_len > 0) ? 1 : 0;
     int log_avail = alt_size - *alt_len - sep;
 
-    if (!alt_buf || log_avail <= 0)
+    if (log_avail <= 0)
         return -1;
 
     length = std::min(length, log_avail - 1);
index f69bfb40e75d112a0259b198cc27b66c0358ce7b..d16da7676f080e3548da1f87e340f20a055d2760 100644 (file)
@@ -68,7 +68,7 @@ struct MimeDataPafInfo
     bool boundary_quoted;
 };
 
-inline bool scanning_boundary(MimeDataPafInfo* mime_info, uint32_t boundary_start, uint32_t* fp)
+inline bool scanning_boundary(const MimeDataPafInfo* mime_info, uint32_t boundary_start, uint32_t* fp)
 {
     if (boundary_start
         && mime_info->data_state != MIME_PAF_FINDING_BOUNDARY_STATE
index 91edc7c7f01d9eae8a2b27ec709598c77c9064e2..054e7a5b3d374126bfd16015a7d0854b03c5f730 100644 (file)
@@ -1,5 +1,5 @@
 if ( HAVE_SAFEC )
-    LIST(APPEND EXTERNAL_LIBRARIES ${SAFEC_LIBRARIES})
+    SET(EXTRA_LIBRARIES ${SAFEC_LIBRARIES})
 endif ()
 
 add_cpputest( file_mime_log_test
@@ -7,5 +7,5 @@ add_cpputest( file_mime_log_test
         ../file_mime_log.cc
         file_mime_log_test.cc
     LIBS
-        ${EXTERNAL_LIBRARIES}
+        ${EXTRA_LIBRARIES}
 )
index 0850c1b4cdb828ddb58541f4c4826c8564d245ea..480fb0b06c34502f795956a21842954bab96414b 100644 (file)
@@ -531,6 +531,7 @@ TEST(mail_log_limit_preset, name_fit)
     uint32_t filename_len = LEN_UNSET;
 
     state->get_file_name(&filename, &filename_len);
+    // cppcheck-suppress syntaxError
     CHECK_COMPARE(SIZE_LIMIT - 1, ==, filename_len);
 
     std::string written((const char*)data, data_len);