]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
fix sip stats and misc static analysis issues
authorRuss Combs <rucombs@cisco.com>
Thu, 2 Jul 2015 19:07:38 +0000 (15:07 -0400)
committerRuss Combs <rucombs@cisco.com>
Thu, 2 Jul 2015 19:07:38 +0000 (15:07 -0400)
src/service_inspectors/sip/ips_sip_method.cc
src/service_inspectors/sip/sip_config.h
src/service_inspectors/sip/sip_dialog.cc
src/service_inspectors/sip/sip_module.cc
src/service_inspectors/sip/sip_module.h
src/service_inspectors/sip/sip_parser.cc

index 43e98e24c4e0dbf824ab8c273621f47971b8deab..df2bf7bcbf97498c2e026989afdac101bb0b07f2 100644 (file)
@@ -196,6 +196,7 @@ bool SipMethodModule::set(const char*, Value& v, SnortConfig*)
         if(!method)
         {
             ParseError("Failed to add a new method to sip_method\n");
+            return false;
         }
 
         smod.flags |= 1 << (method->methodFlag - 1);
index f4d75b7a28beccb60ae13c4d29505eeb4bb80e25..544eed47f8ec4c3b24014edcd6577b7b8af0da51 100644 (file)
@@ -60,8 +60,8 @@ struct SIP_Stats
     PegCount dialogs;
     PegCount ignoreChannels;
     PegCount ignoreSessions;
-    PegCount requests[NUM_OF_REQUEST_TYPES];
-    PegCount responses[NUM_OF_RESPONSE_TYPES];
+    PegCount requests; // [NUM_OF_REQUEST_TYPES];    // FIXIT-L support this
+    PegCount responses; // [NUM_OF_RESPONSE_TYPES];  // FIXIT-L support this
 };
 
 extern THREAD_LOCAL SIP_Stats sip_stats;
index 750d6a7cc8e337f6b87e111e2335418d83585640..8a38ca28b4ee0a613613b1c261541cbb36a368f0 100644 (file)
@@ -80,9 +80,13 @@ static int SIP_processRequest(SIPMsg* sipMsg, SIP_DialogData* dialog, SIP_Dialog
     }
 
     methodFlag = sipMsg->methodFlag;
+#if 1
+    sip_stats.requests++;
+#else
     sip_stats.requests[TOTAL_REQUESTS]++;
     if (methodFlag > 0)
         sip_stats.requests[methodFlag]++;
+#endif
     switch (methodFlag)
     {
     case SIP_METHOD_INVITE:
@@ -233,9 +237,13 @@ static int SIP_processResponse(SIPMsg* sipMsg, SIP_DialogData* dialog, SIP_Dialo
     assert (NULL != sipMsg);
 
     statusType = sipMsg->status_code / 100;
+#if 1
+    sip_stats.responses++;
+#else
     sip_stats.responses[TOTAL_RESPONSES]++;
     if (statusType < NUM_OF_RESPONSE_TYPES)
         sip_stats.responses[statusType]++;
+#endif
 
     if (NULL == dialog)
         return false;
index e31776fb802e3209662521fd81a949ca832448d2..5a69de5b00e1bb8f174a408b10254b1bf8237772 100644 (file)
@@ -131,13 +131,13 @@ static const RuleMap sip_rules[] =
 
 THREAD_LOCAL SIP_Stats sip_stats;
 
-const PegInfo sip_pegs[] =
+static const PegInfo sip_pegs[] =
 {
     { "sessions", "total sessions" },
     { "events", "events generated" },
     { "dialogs", "total dialogs" },
-    { "ignoreChannels", "total channels ignored" },
-    { "ignoreSessions", "total sessions ignored" },
+    { "ignored channels", "total channels ignored" },
+    { "ignored sessions", "total sessions ignored" },
     { "requests", "total requests" },
     { "responses", "total responses" },
     { nullptr, nullptr }
@@ -165,7 +165,7 @@ const PegInfo* SipModule::get_pegs() const
 { return sip_pegs; }
 
 PegCount* SipModule::get_counts() const
-{ return (PegCount*)&sipstats; }
+{ return (PegCount*)&sip_stats; }
 
 ProfileStats* SipModule::get_profile() const
 { return &sipPerfStats; }
index daa22732df426438fa83f761c72cfbc9f8bd9565..2ff0553d0b103157fa5cc07fa57310f3f962f6ea 100644 (file)
@@ -61,7 +61,6 @@
 
 struct SnortConfig;
 
-extern const PegInfo sip_pegs[];
 extern THREAD_LOCAL SimpleStats sipstats;
 extern THREAD_LOCAL ProfileStats sipPerfStats;
 
index 860a5a7c693584a9b3c6f0a63c255116dae3018d..7b03f0cf6d6912e48d92986cfd857cb053ee1cb7 100644 (file)
@@ -250,12 +250,13 @@ static int sip_process_bodyField(SIPMsg* msg, const char* start, const char* end
  ********************************************************************/
 static int sip_find_linebreak(const char* start, char* end, char** lineEnd)
 {
-    int numCRLF;
-    char* s = (char*)start;
+    int numCRLF = 0;
     *lineEnd = NULL;
-    numCRLF = 0;
+
     if (start >= end)
-        return 0;
+        return numCRLF;
+
+    char* s = (char*)start;
 
     while ((s < end) && !('\r' ==*s || '\n' == *s))
     {
@@ -263,7 +264,7 @@ static int sip_find_linebreak(const char* start, char* end, char** lineEnd)
     }
 
     if (s == end)
-        return 0;
+        return numCRLF;
 
     s++;
     numCRLF = 1;
@@ -519,9 +520,12 @@ static int sip_body_parse(SIPMsg* msg, const char* buff, char* end, char** bodyE
     char* next;
     char* start;
     int numOfLineBreaks;
+
+#ifdef DEBUG_MSGS
     length = end - buff;
     DEBUG_WRAP(DebugMessage(DEBUG_SIP, "Body length: %d\n", length); );
     DEBUG_WRAP(DebugMessage(DEBUG_SIP, "Body line: %.*s\n", length, buff); );
+#endif
 
     // Initialize it
     *bodyEnd = end;