From: Russ Combs (rucombs) Date: Fri, 9 Dec 2016 23:12:05 +0000 (-0500) Subject: Merge pull request #745 in SNORT/snort3 from cppchk2 to master X-Git-Tag: 3.0.0-233~149 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02d963852fd25d59609ae43353bfddee3ff681ef;p=thirdparty%2Fsnort3.git Merge pull request #745 in SNORT/snort3 from cppchk2 to master Squashed commit of the following: commit fae5565f41fb7db83287999210d7dda6457b5685 Author: Russ Combs Date: Fri Dec 9 16:27:32 2016 -0500 fix cppcheck warning in ftp params commit f41129dd4622688af4899c1faf9e45b33d90162a Author: Russ Combs Date: Fri Dec 9 15:12:15 2016 -0500 convert stream u2 maps arg to reference commit 3347756cf56413da5a5fdd4210918bb7257a2f86 Author: Russ Combs Date: Fri Dec 9 12:53:28 2016 -0500 fix int vs size_t format issue commit 01ab793e28c8971e2d1094a4b1ea44bf7f68d943 Author: Russ Combs Date: Fri Dec 9 12:34:51 2016 -0500 remove vestigial extra stream debug foo --- diff --git a/src/actions/act_react.cc b/src/actions/act_react.cc index 57c85880d..4b792dd29 100644 --- a/src/actions/act_react.cc +++ b/src/actions/act_react.cc @@ -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; diff --git a/src/loggers/unified2.cc b/src/loggers/unified2.cc index e3056ac73..b724db24a 100644 --- a/src/loggers/unified2.cc +++ b/src/loggers/unified2.cc @@ -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( diff --git a/src/service_inspectors/ftp_telnet/ftp_parse.cc b/src/service_inspectors/ftp_telnet/ftp_parse.cc index 279a9338f..7f91d3290 100644 --- a/src/service_inspectors/ftp_telnet/ftp_parse.cc +++ b/src/service_inspectors/ftp_telnet/ftp_parse.cc @@ -25,9 +25,7 @@ #include "ftp_parse.h" -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif +#include #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; inumChoices; i++) - { - SetOptionalsNext(ThisFmt->choices[i], ThisFmt, - choices, numChoices); - } - SetOptionalsNext(ThisFmt->next_param_fmt, ThisFmt, - choices, numChoices); + + for ( int i=0; inumChoices; i++ ) + SetOptionalsNext(ThisFmt->choices[i], ThisFmt, choices, numChoices); + + SetOptionalsNext(ThisFmt->next_param_fmt, ThisFmt, choices, numChoices); } } diff --git a/src/stream/libtcp/tcp_segment_descriptor.cc b/src/stream/libtcp/tcp_segment_descriptor.cc index bc9fa881c..0f75d821f 100644 --- a/src/stream/libtcp/tcp_segment_descriptor.cc +++ b/src/stream/libtcp/tcp_segment_descriptor.cc @@ -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() diff --git a/src/stream/stream.cc b/src/stream/stream.cc index 7bc86de76..b38941ea6 100644 --- a/src/stream/stream.cc +++ b/src/stream/stream.cc @@ -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) diff --git a/src/stream/stream.h b/src/stream/stream.h index 0afd15720..7863a86d8 100644 --- a/src/stream/stream.h +++ b/src/stream/stream.h @@ -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*); diff --git a/src/stream/tcp/tcp_defs.h b/src/stream/tcp/tcp_defs.h index 23233f0fb..4fd22114c 100644 --- a/src/stream/tcp/tcp_defs.h +++ b/src/stream/tcp/tcp_defs.h @@ -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 diff --git a/src/stream/tcp/tcp_event_logger.cc b/src/stream/tcp/tcp_event_logger.cc index 41e09af2c..75891ba0e 100644 --- a/src/stream/tcp/tcp_event_logger.cc +++ b/src/stream/tcp/tcp_event_logger.cc @@ -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); } }