]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2209 in SNORT/snort3 from ~SBAIGAL/snort3:coverity_fix to master
authorSteve Chew (stechew) <stechew@cisco.com>
Fri, 15 May 2020 19:53:20 +0000 (19:53 +0000)
committerSteve Chew (stechew) <stechew@cisco.com>
Fri, 15 May 2020 19:53:20 +0000 (19:53 +0000)
Squashed commit of the following:

commit 2496431615a57a9656134448372bd54765f22693
Author: Steven Baigal (sbaigal) <sbaigal@cisco.com>
Date:   Wed May 6 16:46:36 2020 -0400

    coverity: fixed issues discovered by Coverity tool

45 files changed:
src/ips_options/ips_asn1.cc
src/ips_options/ips_base64.cc
src/ips_options/ips_ber_data.cc
src/ips_options/ips_ber_skip.cc
src/ips_options/ips_byte_extract.cc
src/ips_options/ips_byte_jump.cc
src/ips_options/ips_byte_math.cc
src/ips_options/ips_byte_test.cc
src/ips_options/ips_classtype.cc
src/ips_options/ips_cvs.cc
src/ips_options/ips_detection_filter.cc
src/ips_options/ips_enable.cc
src/ips_options/ips_flags.cc
src/ips_options/ips_flow.cc
src/ips_options/ips_flowbits.cc
src/ips_options/ips_gid.cc
src/ips_options/ips_hash.cc
src/ips_options/ips_ip_proto.cc
src/ips_options/ips_ipopts.cc
src/ips_options/ips_isdataat.cc
src/ips_options/ips_metadata.cc
src/ips_options/ips_priority.cc
src/ips_options/ips_reference.cc
src/ips_options/ips_regex.cc
src/ips_options/ips_rev.cc
src/ips_options/ips_rpc.cc
src/ips_options/ips_sid.cc
src/ips_options/ips_so.cc
src/ips_options/ips_target.cc
src/loggers/alert_csv.cc
src/loggers/alert_fast.cc
src/loggers/alert_full.cc
src/loggers/alert_json.cc
src/loggers/alert_sf_socket.cc
src/loggers/alert_syslog.cc
src/loggers/alert_unixsock.cc
src/loggers/log_codecs.cc
src/loggers/log_hext.cc
src/loggers/log_pcap.cc
src/loggers/unified2.cc
src/main/control_mgmt.cc
src/managers/so_manager.cc
src/network_inspectors/perf_monitor/cpu_tracker.h
src/network_inspectors/perf_monitor/flow_ip_tracker.cc
src/network_inspectors/perf_monitor/perf_tracker.h

index cb067e213a8cd8ce786006549ffd21eea3d4810e..2abccf341d6d34a456e3c27efb62fd51b2c57d3f 100644 (file)
@@ -209,7 +209,7 @@ public:
     { return DETECT; }
 
 public:
-    ASN1_CTXT data;
+    ASN1_CTXT data = {};
 };
 
 bool Asn1Module::begin(const char*, int, SnortConfig*)
index df31e3ef52df5a6e13489f16eae95c2b1f9aca9d..765118da0edf8090372b51486e697850e06f5991 100644 (file)
@@ -189,7 +189,7 @@ public:
     { return DETECT; }
 
 public:
-    Base64DecodeData data;
+    Base64DecodeData data = {};
 };
 
 bool B64DecodeModule::begin(const char*, int, SnortConfig*)
index 06b521beed6d6d54129979659fe90f692c6b8df6..fe08a1981ab1fe96b4d2117770fd1c7b8c168327 100644 (file)
@@ -128,7 +128,7 @@ public:
     { return DETECT; }
 
 public:
-    uint32_t type;
+    uint32_t type = 0;
 };
 
 bool BerDataModule::begin(const char*, int, SnortConfig*)
index 4d4765cdece634122b2257dc8daf8b36de1cfef1..9ecf370c5bed84acca1f4a51d837ae5953e19ab7 100644 (file)
@@ -139,8 +139,8 @@ public:
     { return DETECT; }
 
 public:
-    uint32_t type;
-    bool optional;
+    uint32_t type = 0;
+    bool optional = false;
 };
 
 bool BerSkipModule::begin(const char*, int, SnortConfig*)
index 9213600c81dfc3dc48c05025a48e73672a3f2d89..2c68e2c519e17123d8037123d7b9f919c10c4a42 100644 (file)
@@ -342,7 +342,7 @@ static const Parameter s_params[] =
 class ExtractModule : public Module
 {
 public:
-    ExtractModule() : Module(s_name, s_help, s_params) { }
+    ExtractModule() : Module(s_name, s_help, s_params) { data.multiplier = 1; }
 
     bool begin(const char*, int, SnortConfig*) override;
     bool end(const char*, int, SnortConfig*) override;
@@ -355,7 +355,7 @@ public:
     { return DETECT; }
 
 public:
-    ByteExtractData data;
+    ByteExtractData data = {};
 };
 
 bool ExtractModule::begin(const char*, int, SnortConfig*)
index ea672a92ca9676d4a18c5f5258de7353e2649998..8cb9e87c2e59797ff3515f4223665e5466290b7c 100644 (file)
@@ -383,7 +383,7 @@ static const Parameter s_params[] =
 class ByteJumpModule : public Module
 {
 public:
-    ByteJumpModule() : Module(s_name, s_help, s_params) { }
+    ByteJumpModule() : Module(s_name, s_help, s_params) { data.multiplier = 1; }
 
     bool begin(const char*, int, SnortConfig*) override;
     bool end(const char*, int, SnortConfig*) override;
@@ -396,7 +396,7 @@ public:
     { return DETECT; }
 
 public:
-    ByteJumpData data;
+    ByteJumpData data = {};
     string var;
     string post_var;
 };
index 68b47d2cdf320d213685e96c4cd5950cefbaa946..d7137ef25ba9606cf71f2b0ee7692338247bd312 100644 (file)
@@ -367,7 +367,7 @@ public:
     { return DETECT; }
 
 public:
-    ByteMathData data;
+    ByteMathData data = {};
     string rvalue_var;
     string off_var;
 };
index 2ad0b406e31fb5e2dfb29b40a19627937b64318e..a4be24e807bbe88dff0945fe537b80f9e7709e17 100644 (file)
@@ -478,7 +478,7 @@ public:
     { return DETECT; }
 
 public:
-    ByteTestData data;
+    ByteTestData data = {};
     string cmp_var;
     string off_var;
 };
index 70f842ba8bafed4518a177d22fe6421e529b28dd..b64ee645de68750c9862139706e85f9f5fc59d6f 100644 (file)
@@ -56,7 +56,7 @@ public:
     { return DETECT; }
 
 public:
-    const ClassType* type;
+    const ClassType* type = nullptr;
 };
 
 bool ClassTypeModule::set(const char*, Value& v, SnortConfig* sc)
index b17c8f893a3e2a37a340c394bb6f6f043d7abd2a..58af1300bb397bb594eec219c0923fd927be27f3 100644 (file)
@@ -401,7 +401,7 @@ public:
     { return DETECT; }
 
 public:
-    CvsRuleOption data;
+    CvsRuleOption data = {};
 };
 
 bool CvsModule::begin(const char*, int, SnortConfig*)
index 1dfc811a8e506fe13968e27df99267950526d520..5f1132d59b0733ef7fab00e98f0d9935f2a706fe 100644 (file)
@@ -68,8 +68,8 @@ public:
     { return DETECT; }
 
 public:
-    THDX_STRUCT thdx;
-    DetectionFilterConfig* dfc;
+    THDX_STRUCT thdx = {};
+    DetectionFilterConfig* dfc = nullptr;
 };
 
 bool DetectionFilterModule::begin(const char*, int, SnortConfig* sc)
index eda285c03092a30a794ff7a77b7f508f1ea61ef1..4d0014be4ef2613f82b3e7eeb34aec268d9e7bde 100644 (file)
@@ -58,7 +58,7 @@ public:
     { return DETECT; }
 
 public:
-    IpsPolicy::Enable enable;
+    IpsPolicy::Enable enable = IpsPolicy::Enable::ENABLED;
 };
 
 bool EnableModule::begin(const char*, int, SnortConfig* sc)
index b0453a83092978e48819b97b636b8d0fed25caac..b505d217789bf32566756e865242638ba2e0ba07 100644 (file)
@@ -357,7 +357,7 @@ public:
     { return DETECT; }
 
 public:
-    TcpFlagCheckData data;
+    TcpFlagCheckData data = {};
 };
 
 bool FlagsModule::begin(const char*, int, SnortConfig*)
index 789c44bbd87417a9be373d1b985ec50ec5bd1f43..bedf084aa458e631d945167e630ed4bc1595018b 100644 (file)
@@ -340,7 +340,7 @@ public:
     { return DETECT; }
 
 public:
-    FlowCheckData data;
+    FlowCheckData data = {};
 };
 
 bool FlowModule::begin(const char*, int, SnortConfig*)
index 25d1ad576812836edc7b20eed50f7f69e31e19af..ed6c72bbc9262de9cf4c8642784fc691874b97de 100644 (file)
@@ -467,7 +467,7 @@ public:
     FlowBitCheck* get_data();
 
 public:
-    FlowBitCheck::Op op;
+    FlowBitCheck::Op op = FlowBitCheck::Op::SET;
     std::string bits;
     FlowBitCheck* fbc = nullptr;
 };
index 80a2f232f23485c4e9d3778c009cf1225e52b39f..15edae441a57fe1c93b4e280369db842eb5a6e17 100644 (file)
@@ -55,7 +55,7 @@ public:
     { return DETECT; }
 
 public:
-    uint32_t gid;
+    uint32_t gid = 0;
 };
 
 bool GidModule::set(const char*, Value& v, SnortConfig*)
index 1023b1795c0ac29b8939b7be12843022028f93c9..f367ba418a8be9fb309632ca3beba98b332d93af 100644 (file)
@@ -223,7 +223,8 @@ IpsOption::EvalStatus HashOption::eval(Cursor& c, Packet*)
 
 static void parse_hash(HashMatchData* hmd, const char* rule)
 {
-    parse_byte_code(rule, hmd->negated, hmd->hash);
+    if (!parse_byte_code(rule, hmd->negated, hmd->hash))
+        ParseError("Invalid hash");
 }
 
 // FIXIT-L refactor for general use?
index c263d595ecf7ba46873920f741d3b3812442def5..ce9cbf95317bf4046e36b0507b4d8ce8b534a40a 100644 (file)
@@ -239,7 +239,7 @@ public:
     { return DETECT; }
 
 public:
-    IpProtoData data;
+    IpProtoData data = {};
 };
 
 bool IpProtoModule::begin(const char*, int, SnortConfig*)
index 48c0480d39d29439449d27afef46f692e6ebc329..c3fcd271b4d58c3ef6eab2829f9aeec28554b773 100644 (file)
@@ -212,7 +212,7 @@ public:
     { return DETECT; }
 
 public:
-    IpOptionData data;
+    IpOptionData data = {};
 };
 
 bool IpOptModule::begin(const char*, int, SnortConfig*)
index 37df2ddac3254e377329d66ef917e17d661fea47..15b9a75530f81219c0bcf276301f5326997ee80a 100644 (file)
@@ -246,7 +246,7 @@ public:
     { return DETECT; }
 
 public:
-    IsDataAtData data;
+    IsDataAtData data = {};
 };
 
 bool IsDataAtModule::begin(const char*, int, SnortConfig*)
index 962882de0446160b1bd87d3f62d99c4b7120a91f..5c6a36878764b76a0b99ca5fddf585c96880c506 100644 (file)
@@ -58,7 +58,7 @@ public:
     Usage get_usage() const override
     { return DETECT; }
 
-    bool match;
+    bool match = false;
 };
 
 bool MetadataModule::begin(const char*, int, SnortConfig*)
index 1f3718e0e12c27c8068fe1e2037cd4b63e4af4e5..742859c57ed33639c627d4cd744b38a2271d08d6 100644 (file)
@@ -55,7 +55,7 @@ public:
     { return DETECT; }
 
 public:
-    int priority;
+    int priority = 0;
 };
 
 bool PriorityModule::set(const char*, Value& v, SnortConfig*)
index 78f5cf9ba634efc5d51556f1bc6411ebccdb1473..4d2c89ef931c0859cbb9df62d1bc3b9eef6c4447 100644 (file)
@@ -59,7 +59,7 @@ public:
 public:
     std::string scheme;
     std::string id;
-    SnortConfig* snort_config;
+    SnortConfig* snort_config = nullptr;
 };
 
 bool ReferenceModule::begin(const char*, int, SnortConfig* sc)
index 6159e5e230bc8c7cd17047a441a539bf09cf32d0..c99ddcc24f2a39a4fde74ad62bcdc9c15f94ca0d 100644 (file)
@@ -278,7 +278,7 @@ bool RegexModule::begin(const char* name, int, SnortConfig*)
 bool RegexModule::convert_pcre_to_regex_form()
 {
     size_t pos = config.re.find_first_of("\"!");
-    if (config.re[pos] == '!')
+    if (pos != std::string::npos and config.re[pos] == '!')
         return false;
 
     config.re.erase(0,2);
index 07c043d6d5024abf7ba632f6be104f7e35ee90ad..a1af281c9c28f9b84937f9e990ab5926d3dab89b 100644 (file)
@@ -55,7 +55,7 @@ public:
     { return DETECT; }
 
 public:
-    uint32_t rev;
+    uint32_t rev = 0;
 };
 
 bool RevModule::set(const char*, Value& v, SnortConfig*)
index 7c3f27eb9ac4e5385bc909e3d2cd1c3f5fc2406c..89b8b29855fea0e7c3c5771a534500269112a994 100644 (file)
@@ -257,7 +257,7 @@ public:
     { return DETECT; }
 
 public:
-    RpcCheckData data;
+    RpcCheckData data = {};
 };
 
 bool RpcModule::begin(const char*, int, SnortConfig*)
index ef67f1c27f8b3ef759ce9378ea39c6d671519efd..8695d6c4625dbc08a74ca29d93b811f9e8d86407 100644 (file)
@@ -55,7 +55,7 @@ public:
     { return DETECT; }
 
 public:
-    uint32_t sid;
+    uint32_t sid = 0;
 };
 
 bool SidModule::set(const char*, Value& v, SnortConfig*)
index f9470221089cbd58c87831f573825d8ba14145a6..3467ecb85ffa9299399bca2779546f47c9fa83ee 100644 (file)
@@ -143,8 +143,8 @@ public:
 
 public:
     string name;
-    bool relative_flag;
-    SnortConfig* cfg;
+    bool relative_flag = false;
+    SnortConfig* cfg = nullptr;
 };
 
 bool SoModule::begin(const char*, int, SnortConfig* sc)
index 68c54caa608b9f187e204589e9f4dbf5bd2733bd..7481aa63e9e72c26f6812803aafb99d1e5ab3e03 100644 (file)
@@ -55,7 +55,7 @@ public:
     { return DETECT; }
 
 public:
-    Target target;
+    Target target = Target::TARGET_NONE;
 };
 
 bool TargetModule::set(const char*, Value& v, SnortConfig*)
index 9ae5838ea0f7553cac72feabcdfe4fdacce6c60c..f223b1a2ca3f2b02f5cccb373ce9ed8587ec15f8 100644 (file)
@@ -207,7 +207,7 @@ static void ff_eth_type(const Args& a)
 static void ff_flowstart_time(const Args& a)
 {
     if (a.pkt->flow)
-        TextLog_Print(csv_log, "%u", a.pkt->flow->flowstats.start_time.tv_sec);
+        TextLog_Print(csv_log, "%lu", a.pkt->flow->flowstats.start_time.tv_sec);
 }
 
 static void ff_gid(const Args& a)
@@ -318,7 +318,7 @@ static void ff_rule(const Args& a)
 
 static void ff_seconds(const Args& a)
 {
-    TextLog_Print(csv_log, "%u",  a.pkt->pkth->ts.tv_sec);
+    TextLog_Print(csv_log, "%lu",  a.pkt->pkth->ts.tv_sec);
 }
 
 static void ff_server_bytes(const Args& a)
@@ -525,8 +525,8 @@ public:
     { return GLOBAL; }
 
 public:
-    bool file;
-    size_t limit;
+    bool file = false;
+    size_t limit = 0;
     string sep;
     vector<CsvFunc> fields;
 };
@@ -543,7 +543,11 @@ bool CsvModule::set(const char*, Value& v, SnortConfig*)
         fields.clear();
 
         while ( v.get_next_token(tok) )
-            fields.emplace_back(csv_func[Parameter::index(csv_range, tok.c_str())]);
+        {
+            int i = Parameter::index(csv_range, tok.c_str());
+            if ( i >= 0 )
+                fields.emplace_back(csv_func[i]);
+        }
     }
 
     else if ( v.is("limit") )
@@ -571,7 +575,11 @@ bool CsvModule::begin(const char*, int, SnortConfig*)
         v.set_first_token();
 
         while ( v.get_next_token(tok) )
-            fields.emplace_back(csv_func[Parameter::index(csv_range, tok.c_str())]);
+        {
+            int i = Parameter::index(csv_range, tok.c_str());
+            if ( i >= 0 )
+                fields.emplace_back(csv_func[i]);
+        }
     }
     return true;
 }
index 26a7befd0a2e75080a4fafda112e4ff49ceedd69..7ffd70ee6bc46d0556ebe3a28b023dca0948ea7c 100644 (file)
@@ -101,9 +101,9 @@ public:
     { return GLOBAL; }
 
 public:
-    size_t limit;
-    bool file;
-    bool packet;
+    size_t limit = 0;
+    bool file = false;
+    bool packet = false;
 };
 
 bool FastModule::set(const char*, Value& v, SnortConfig*)
index 65225603f8b535d34e9fa18944d23cc7c9d2ae80..4de7f371274152e7c03bfcc52b2adb4f7fee190e 100644 (file)
@@ -87,8 +87,8 @@ public:
     { return GLOBAL; }
 
 public:
-    bool file;
-    size_t limit;
+    bool file = false;
+    size_t limit = 0;
 };
 
 bool FullModule::set(const char*, Value& v, SnortConfig*)
index cf702530073eb5f8b1c03fa5c0896c17879f405c..41255f18e135c5f4aaf487550d6cfe99ea05558b 100644 (file)
@@ -262,7 +262,7 @@ static bool ff_flowstart_time(const Args& a)
     if (a.pkt->flow)
     {
         print_label(a, "flowstart_time");
-        TextLog_Print(json_log, "%u", a.pkt->flow->flowstats.start_time.tv_sec);
+        TextLog_Print(json_log, "%lu", a.pkt->flow->flowstats.start_time.tv_sec);
         return true;
     }
     return false;
@@ -433,7 +433,7 @@ static bool ff_rule(const Args& a)
 static bool ff_seconds(const Args& a)
 {
     print_label(a, "seconds");
-    TextLog_Print(json_log, "%u",  a.pkt->pkth->ts.tv_sec);
+    TextLog_Print(json_log, "%lu",  a.pkt->pkth->ts.tv_sec);
     return true;
 }
 
@@ -717,8 +717,8 @@ public:
     { return GLOBAL; }
 
 public:
-    bool file;
-    size_t limit;
+    bool file = false;
+    size_t limit = 0;
     string sep;
     vector<JsonFunc> fields;
 };
@@ -735,7 +735,11 @@ bool JsonModule::set(const char*, Value& v, SnortConfig*)
         fields.clear();
 
         while ( v.get_next_token(tok) )
-            fields.emplace_back(json_func[Parameter::index(json_range, tok.c_str())]);
+        {
+            int i = Parameter::index(json_range, tok.c_str());
+            if ( i >= 0 )
+                fields.emplace_back(json_func[i]);
+        }
     }
 
     else if ( v.is("limit") )
@@ -763,7 +767,11 @@ bool JsonModule::begin(const char*, int, SnortConfig*)
         v.set_first_token();
 
         while ( v.get_next_token(tok) )
-            fields.emplace_back(json_func[Parameter::index(json_range, tok.c_str())]);
+        {
+            int i = Parameter::index(json_range, tok.c_str());
+            if ( i >= 0 )
+                fields.emplace_back(json_func[i]);
+        }
     }
     return true;
 }
index 92469fb225a9eb71b03dfbfd3937c0d6d27bdbbc..9c15e4b4a15ebd1e04ede6fcad79c262402c1588 100644 (file)
@@ -38,6 +38,7 @@
 #include "protocols/packet.h"
 #include "target_based/snort_protocols.h"
 #include "utils/util.h"
+#include "utils/util_cstring.h"
 
 using namespace snort;
 using namespace std;
@@ -105,7 +106,7 @@ public:
 public:
     string file;
     RuleVector rulez;
-    RuleId rule;
+    RuleId rule = {};
 };
 
 bool SfSocketModule::set(const char*, Value& v, SnortConfig*)
@@ -173,7 +174,7 @@ static void sock_init(const char* args)
 
     memset(&context.addr, 0, sizeof(context.addr));
     context.addr.sun_family = AF_UNIX;
-    memcpy(context.addr.sun_path + 1, name.c_str(), strlen(name.c_str()));
+    SnortStrncpy(context.addr.sun_path, name.c_str(), sizeof(context.addr.sun_path));
 
     if (AlertSFSocket_Connect() == 0)
         context.connected = 1;
index 3f7fd0ee703df58fcf8e10a1296c7fcf2e4d3e93..1cc4f88ede5c2fef46f501c65869a4f5db8fa161 100644 (file)
@@ -151,9 +151,9 @@ public:
     { return GLOBAL; }
 
 public:
-    int facility;
-    int level;
-    int options;
+    int facility = 0;
+    int level = 0;
+    int options = 0;
 };
 
 bool SyslogModule::set(const char*, Value& v, SnortConfig*)
index bbe25d291cfc8d5bbed8c9b5dbebed3f2755a578..c20834853b9ea13fba26832ca88b306e6dfae59d 100644 (file)
@@ -31,6 +31,7 @@
 #include "log/messages.h"
 #include "protocols/packet.h"
 #include "utils/util.h"
+#include "utils/util_cstring.h"
 
 using namespace snort;
 
@@ -212,7 +213,7 @@ static void OpenAlertSock()
     us.addr.sun_family = AF_UNIX;
 
     /* copy path over and preserve a null byte at the end */
-    strncpy(us.addr.sun_path, name.c_str(), sizeof(us.addr.sun_path)-1);
+    SnortStrncpy(us.addr.sun_path, name.c_str(), sizeof(us.addr.sun_path));
 
     if ( (us.socket = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0 )
         FatalError("socket() call failed: %s", get_error(errno));
index 67814976af9d05af8c45e026ba3aad9e9033c1c8..aac88c176492f7519755c8f2dcfc40d3073f2cd3 100644 (file)
@@ -71,8 +71,8 @@ public:
     { return GLOBAL; }
 
 public:
-    bool print_to_file;
-    uint8_t flags;
+    bool print_to_file = false;
+    uint8_t flags = 0;
 };
 } // namespace
 
index 0dd4c6ef00c969540a1c08622de9c1c1370eaa89..eea98a90172c16c07fafd39fe417233eefc86667 100644 (file)
@@ -82,7 +82,7 @@ void DaqMessageEventHandler::handle(DataEvent& event, Flow*)
     int vlan_tag = fs->vlan_tag == 0xfff ?  0 : fs->vlan_tag;
 
     TextLog_Print(hext_log,
-        "\n$%s %d %d %d %d %s %d %s %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
+        "\n$%s %d %d %d %d %s %d %s %d %u %lu %lu %lu %lu %lu %lu %d %lu %lu %d %d %d\n",
         cmd,
         fs->ingressZone,
         fs->egressZone,
@@ -196,10 +196,10 @@ public:
     { return GLOBAL; }
 
 public:
-    bool file;
-    bool raw;
-    size_t limit;
-    unsigned width;
+    bool file = false;
+    bool raw = false;
+    size_t limit = 0;
+    unsigned width = 20;
 };
 
 bool HextModule::set(const char*, Value& v, SnortConfig*)
index ccdc1791c3c5d34bdda23ff2a4b588f9519791e4..55a5569b7f83d2337557212f9dbacd059a4fe1de 100644 (file)
@@ -96,7 +96,7 @@ public:
     { return GLOBAL; }
 
 public:
-    size_t limit;
+    size_t limit = 0;
 };
 
 bool TcpdumpModule::set(const char*, Value& v, SnortConfig*)
index 29cbee71d4834f4598e7e29881380f92f353d69d..940a8e4521b8091b14d3dcb4d83f2443f16522fe 100644 (file)
@@ -335,7 +335,7 @@ static void _Unified2LogPacketAlert(
     unsigned u2_type, U2PseudoHeader* u2h = nullptr)
 {
     Serial_Unified2_Header hdr;
-    Serial_Unified2Packet logheader;
+    Serial_Unified2Packet logheader = {};
 
     uint32_t pkt_length = 0;
     uint32_t write_len = sizeof(hdr) + sizeof(Serial_Unified2Packet) - 4;
@@ -817,9 +817,9 @@ public:
     { return GLOBAL; }
 
 public:
-    size_t limit;
-    bool nostamp;
-    bool legacy_events;
+    size_t limit = 0;
+    bool nostamp = true;
+    bool legacy_events = false;
 };
 
 bool U2Module::set(const char*, Value& v, SnortConfig*)
index f2791280ee7b5e19cbf9c68f3bee0dc058cb90ff..fabb4f8d56dae16df8c44f39d4737e1f43086108 100644 (file)
@@ -36,6 +36,7 @@
 #include "control.h"
 #include "request.h"
 #include "snort_config.h"
+#include "utils/util_cstring.h"
 
 using namespace snort;
 using namespace std;
@@ -460,7 +461,7 @@ int ControlMgmt::setup_socket_family()
 
         memset(&unix_addr, 0, sizeof(unix_addr));
         unix_addr.sun_family = AF_UNIX;
-        strncpy(unix_addr.sun_path, fullpath.c_str(), sizeof(unix_addr.sun_path)-1);
+        SnortStrncpy(unix_addr.sun_path, fullpath.c_str(), sizeof(unix_addr.sun_path));
         sock_addr = (struct sockaddr*)&unix_addr;
         sock_addr_size = sizeof(unix_addr);
         unlink(fullpath.c_str());
index f2eeec4a9d1d8a780a8c7789c5abb71cb05ac884..1dc4e16dd385b852c11471fe3c80d40ec1abfe40 100644 (file)
@@ -296,6 +296,7 @@ void SoManager::rule_to_hex(const char*)
 
     const unsigned hex_per_row = 16;
 
+    std::ios_base::fmtflags f(cout.flags());
     cout << "static const uint8_t rule_" << var;
     cout << "[] =" << endl;
     cout << "{" << endl << "   ";
@@ -316,6 +317,7 @@ void SoManager::rule_to_hex(const char*)
     cout << "};" << endl;
     cout << "static const unsigned rule_" << var << "_len = ";
     cout << data.size() << ";" << endl;
+    cout.flags(f);
 }
 
 void SoManager::rule_to_text(const char* delim)
index e44881583a71ad4e11d8599d6b88c742df3c0c02..f28e86f52793eafbcf318f9dad79b0801e5b0c2f 100644 (file)
@@ -37,9 +37,9 @@ protected:
 private:
     //19 bits for microseconds
     //45 bits for seconds (out to year 1116918)
-    uint64_t last_wt;
-    uint64_t last_ut;
-    uint64_t last_st;
+    uint64_t last_wt = 0;
+    uint64_t last_ut = 0;
+    uint64_t last_st = 0;
 
     PegCount user_stat;
     PegCount system_stat;
index 9a4d0c5ac39124a6d66e1d87d73f8833e3f2db40..94f568284cb64bfc131656d4f12a43e7fc2603e3 100644 (file)
@@ -129,6 +129,7 @@ FlowIPTracker::FlowIPTracker(PerfConfig* perf) : PerfTracker(perf, TRACKER_NAME)
     formatter->register_field("udp_created", (PegCount*)
         &stats.state_changes[SFS_STATE_UDP_CREATED]);
     formatter->finalize_fields();
+    stats.total_packets = stats.total_bytes = 0;
 
     memcap = perf->flowip_memcap;
     ip_map = new XHash(DEFAULT_XHASH_NROWS, sizeof(FlowStateKey), sizeof(FlowStateValue), memcap);
index 1686287489f865ef178e5a8271f0af61693b5e01..0a0f814ded604036987ba1d97e454a46d9cad736 100644 (file)
@@ -73,13 +73,13 @@ protected:
     virtual void write();
 
     uint64_t max_file_size = 0;
-    PerfFormatter* formatter;
+    PerfFormatter* formatter = nullptr;
 
 private:
     std::string fname;
     std::string tracker_name;
     FILE* fh = nullptr;
-    time_t cur_time;
+    time_t cur_time = 0;
 };
 #endif