]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #745 in SNORT/snort3 from cppchk2 to master
authorRuss Combs (rucombs) <rucombs@cisco.com>
Fri, 9 Dec 2016 23:12:05 +0000 (18:12 -0500)
committerRuss Combs (rucombs) <rucombs@cisco.com>
Fri, 9 Dec 2016 23:12:05 +0000 (18:12 -0500)
Squashed commit of the following:

commit fae5565f41fb7db83287999210d7dda6457b5685
Author: Russ Combs <rucombs@cisco.com>
Date:   Fri Dec 9 16:27:32 2016 -0500

    fix cppcheck warning in ftp params

commit f41129dd4622688af4899c1faf9e45b33d90162a
Author: Russ Combs <rucombs@cisco.com>
Date:   Fri Dec 9 15:12:15 2016 -0500

    convert stream u2 maps arg to reference

commit 3347756cf56413da5a5fdd4210918bb7257a2f86
Author: Russ Combs <rucombs@cisco.com>
Date:   Fri Dec 9 12:53:28 2016 -0500

    fix int vs size_t format issue

commit 01ab793e28c8971e2d1094a4b1ea44bf7f68d943
Author: Russ Combs <rucombs@cisco.com>
Date:   Fri Dec 9 12:34:51 2016 -0500

    remove vestigial extra stream debug foo

src/actions/act_react.cc
src/loggers/unified2.cc
src/service_inspectors/ftp_telnet/ftp_parse.cc
src/stream/libtcp/tcp_segment_descriptor.cc
src/stream/stream.cc
src/stream/stream.h
src/stream/tcp/tcp_defs.h
src/stream/tcp/tcp_event_logger.cc

index 57c85880da1b003194dce611c33f03e1ab7a0454..4b792dd2916cea9575d277a208c935326c578d9d 100644 (file)
@@ -230,7 +230,7 @@ static bool react_getpage(const char* file)
 // format response buffer
 static void react_config(ReactData* rd)
 {
-    size_t body_len, head_len, total_len;
+    int body_len, head_len, total_len;
     char dummy;
 
     const char* head = DEFAULT_HTTP;
index e3056ac73edae8dd567f9691b5d25f35d5c41b40..b724db24a5cb78326e6626ebfe06bc75e46b58bb 100644 (file)
@@ -918,7 +918,7 @@ void U2Logger::alert(Packet* p, const char* msg, Event* event)
     if ( p->xtradata_mask )
     {
         LogFunction* log_funcs;
-        uint32_t max_count = Stream::get_xtra_data_map(&log_funcs);
+        uint32_t max_count = Stream::get_xtra_data_map(log_funcs);
 
         if ( max_count > 0 )
             AlertExtraData(
index 279a9338f9be25dd6c08d645597bb214a6449893..7f91d3290764fc9c05feb9e5b96d0d33b43d497c 100644 (file)
@@ -25,9 +25,7 @@
 
 #include "ftp_parse.h"
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+#include <assert.h>
 
 #include "ftp_bounce_lookup.h"
 #include "ftp_cmd_lookup.h"
@@ -118,62 +116,43 @@ static char* NextToken(const char* delimiters)
     return retTok;
 }
 
-/*
- * Function: SetOptionalsNext(FTP_PARAM_FMT *ThisFmt,
- *                            FTP_PARAM_FMT *NextFmt,
- *                            FTP_PARAM_FMT **choices,
- *                            int numChoices)
- *
- * Purpose: Recursively updates the next value for nodes in the FTP
- *          Parameter validation tree.
- *
- * Arguments: ThisFmt       => pointer to an FTP parameter validation node
- *            NextFmt       => pointer to an FTP parameter validation node
- *            choices       => pointer to a list of FTP parameter
- *                             validation nodes
- *            numChoices    => the number of nodes in the list
- *
- * Returns: int     => an error code integer (0 = success,
- *                     >0 = non-fatal error, <0 = fatal error)
- *
- */
-static void SetOptionalsNext(FTP_PARAM_FMT* ThisFmt, FTP_PARAM_FMT* NextFmt,
+// Recursively update the next value for nodes in the FTP Parameter validation tree.
+
+static void SetOptionalsNext(
+    FTP_PARAM_FMT* ThisFmt, FTP_PARAM_FMT* NextFmt,
     FTP_PARAM_FMT** choices, int numChoices)
 {
-    if (!ThisFmt)
+    if ( !ThisFmt )
         return;
 
-    if (ThisFmt->optional)
+    if ( ThisFmt->optional )
     {
-        if (ThisFmt->next_param_fmt == NULL)
+        if ( ThisFmt->next_param_fmt )
+            SetOptionalsNext(ThisFmt->next_param_fmt, NextFmt, choices, numChoices);
+
+        else
         {
             ThisFmt->next_param_fmt = NextFmt;
-            if (numChoices)
+
+            if ( numChoices )
             {
+                assert(choices);
                 ThisFmt->numChoices = numChoices;
                 ThisFmt->choices =
                     (FTP_PARAM_FMT**)snort_calloc(numChoices, sizeof(FTP_PARAM_FMT*));
                 memcpy(ThisFmt->choices, choices, sizeof(FTP_PARAM_FMT*) * numChoices);
             }
         }
-        else
-        {
-            SetOptionalsNext(ThisFmt->next_param_fmt, NextFmt,
-                choices, numChoices);
-        }
     }
     else
     {
-        int i;
         SetOptionalsNext(ThisFmt->optional_fmt, ThisFmt->next_param_fmt,
             ThisFmt->choices, ThisFmt->numChoices);
-        for (i=0; i<ThisFmt->numChoices; i++)
-        {
-            SetOptionalsNext(ThisFmt->choices[i], ThisFmt,
-                choices, numChoices);
-        }
-        SetOptionalsNext(ThisFmt->next_param_fmt, ThisFmt,
-            choices, numChoices);
+
+        for ( int i=0; i<ThisFmt->numChoices; i++ )
+            SetOptionalsNext(ThisFmt->choices[i], ThisFmt, choices, numChoices);
+
+        SetOptionalsNext(ThisFmt->next_param_fmt, ThisFmt, choices, numChoices);
     }
 }
 
index bc9fa881cf693e7eb1ecd61218cb6a6489b570a9..0f75d821fbdb5c7f95b6260d01c8d2971ca249c9 100644 (file)
@@ -49,14 +49,6 @@ TcpSegmentDescriptor::TcpSegmentDescriptor(Flow* flow, Packet* pkt, TcpEventLogg
         if ( !tcph->is_ack() )
             tel.log_internal_event(INTERNAL_EVENT_SYN_RECEIVED);
     }
-
-#ifdef DEBUG_STREAM_EX
-    LogMessage("Tcp Segment Descriptor:\n");
-    LogMessage("    seq:    0x%08X\n", seg_seq);
-    LogMessage("    ack:    0x%08X\n", seg_ack);
-    LogMessage("    win:    %d\n", seg_wnd);
-    LogMessage("    end:    0x%08X\n", end_seq);
-#endif
 }
 
 TcpSegmentDescriptor::~TcpSegmentDescriptor()
index 7bc86de76ab44e91671d97619904ca778219d116..b38941ea62b905323a89e52022b7720c81854237 100644 (file)
@@ -560,14 +560,10 @@ uint32_t Stream::reg_xtra_data_cb(LogFunction f)
     return stream.xtradata_func_count;
 }
 
-uint32_t Stream::get_xtra_data_map(LogFunction** f)
+uint32_t Stream::get_xtra_data_map(LogFunction*& f)
 {
-    if (f)
-    {
-        *f = stream.xtradata_map;
-        return stream.xtradata_func_count;
-    }
-    return 0;
+    f = stream.xtradata_map;
+    return stream.xtradata_func_count;
 }
 
 void Stream::reg_xtra_data_log(LogExtraData f, void* config)
index 0afd15720bcfb965921ab9c0867a4ec67a53ac50..7863a86d8c12ad6692551e68621105d8fb86b18d 100644 (file)
@@ -237,7 +237,7 @@ public:
 
     static uint32_t reg_xtra_data_cb(LogFunction);
     static void reg_xtra_data_log(LogExtraData, void*);
-    static uint32_t get_xtra_data_map(LogFunction**);
+    static uint32_t get_xtra_data_map(LogFunction*&);
 
 private:
     static void set_ip_protocol(Flow*);
index 23233f0fb9fcb8b7a1dd3b200e0f28eb79aef149..4fd22114ca2d6d6a1304c7b4b4e48e99a169bdd6 100644 (file)
@@ -147,12 +147,5 @@ enum FlushPolicy
 
 extern THREAD_LOCAL Packet* s5_pkt;
 
-//#define DEBUG_STREAM_EX
-#ifdef DEBUG_STREAM_EX
-#define STREAM_DEBUG_WRAP(x) DEBUG_WRAP(x)
-#else
-#define STREAM_DEBUG_WRAP(x)
-#endif
-
 #endif
 
index 41e09af2c1df4585a870542a6055e851e5a1aab8..75891ba0ec622e833b2b35482658482d5c2a9e72 100644 (file)
@@ -90,11 +90,8 @@ void TcpEventLogger::log_internal_event(uint32_t eventSid)
     if (is_internal_event_enabled(snort_conf->rate_filter_config, eventSid))
     {
         tcpStats.internalEvents++;
-
-        STREAM_DEBUG_WRAP(DebugMessage(DEBUG_STREAM_STATE, "Stream raised internal event %d\n",
-                eventSid); );
-
         SnortEventqAdd(GENERATOR_INTERNAL, eventSid);
+        DebugFormat(DEBUG_STREAM, "Stream raised internal event %d\n", eventSid);
     }
 }