]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2574 in SNORT/snort3 from ~MIALTIZE/snort3:zero_init to master
authorMichael Altizer (mialtize) <mialtize@cisco.com>
Fri, 23 Oct 2020 19:57:39 +0000 (19:57 +0000)
committerMichael Altizer (mialtize) <mialtize@cisco.com>
Fri, 23 Oct 2020 19:57:39 +0000 (19:57 +0000)
Squashed commit of the following:

commit d544e08894a7286b156c886e13c1df1c88b62492
Author: Michael Altizer <mialtize@cisco.com>
Date:   Fri Oct 23 15:10:34 2020 -0400

    src: Clean up zero-initialization of arrays

16 files changed:
src/connectors/tcp_connector/tcp_connector.cc
src/detection/fp_create.cc
src/host_tracker/host_tracker.h
src/main/snort_config.cc
src/network_inspectors/appid/appid_debug.cc
src/network_inspectors/appid/appid_http_session.h
src/network_inspectors/appid/appid_peg_counts.h
src/network_inspectors/appid/detector_plugins/detector_imap.cc
src/network_inspectors/appid/detector_plugins/detector_pattern.h
src/network_inspectors/appid/detector_plugins/http_url_patterns.cc
src/network_inspectors/appid/detector_plugins/http_url_patterns.h
src/network_inspectors/packet_tracer/packet_tracer.cc
src/network_inspectors/rna/rna_logger.cc
src/service_inspectors/ftp_telnet/ftp_print.cc
src/service_inspectors/http2_inspect/http2_module.cc
src/service_inspectors/http_inspect/http_module.cc

index 20940f58b3d72ecbb47d468a7bb3dbd3ebc11f65..936f805589d8289b7fbf36bf3a0f590c8dea29bd 100644 (file)
@@ -168,7 +168,7 @@ void TcpConnector::process_receive()
         if (errno != EINTR)
         {
 
-            char error_msg[1024] = {0};
+            char error_msg[1024] = { '\0' };
             if (strerror_r(errno, error_msg, sizeof(error_msg)) == 0)
                 ErrorMessage("TcpC Input Thread: Error polling on socket %d: %s\n", pfds[0].fd, error_msg);
             else
@@ -399,7 +399,7 @@ static TcpConnector* tcp_connector_tinit_answer(TcpConnectorConfig* cfg, const c
 
     if ( listen(sfd, 10) < 0 )
     {
-        char error_msg[1024] = {0};
+        char error_msg[1024] = { '\0' };
         if (strerror_r(errno, error_msg, sizeof(error_msg)) == 0)
             ErrorMessage("listen() failure: %s\n", error_msg);
         else
@@ -409,7 +409,7 @@ static TcpConnector* tcp_connector_tinit_answer(TcpConnectorConfig* cfg, const c
 
     if ( (peer_sfd = accept(sfd, nullptr, nullptr )) < 0 )
     {
-        char error_msg[1024] = {0};
+        char error_msg[1024] = { '\0' };
         if (strerror_r(errno, error_msg, sizeof(error_msg)) == 0)
             ErrorMessage("accept() failure: %s\n", error_msg);
         else
index cbc8405a216c01198a6839186aa00c278bbb1941..059a14f1cb9128556faadd0b8d10da0a17bbc129 100644 (file)
@@ -1423,8 +1423,8 @@ static void fp_sum_service_groups(GHash* h, unsigned c[PM_TYPE_MAX])
 
 static void fp_print_service_groups(srmm_table_t* srmm)
 {
-    unsigned to_srv[PM_TYPE_MAX] = { };
-    unsigned to_cli[PM_TYPE_MAX] = { };
+    unsigned to_srv[PM_TYPE_MAX] = { };
+    unsigned to_cli[PM_TYPE_MAX] = { };
 
     fp_sum_service_groups(srmm->to_srv, to_srv);
     fp_sum_service_groups(srmm->to_cli, to_cli);
@@ -1460,9 +1460,9 @@ static void fp_sum_port_groups(PortTable* tab, unsigned c[PM_TYPE_MAX])
 
 static void fp_print_port_groups(RulePortTables* port_tables)
 {
-    unsigned src[PM_TYPE_MAX] = { };
-    unsigned dst[PM_TYPE_MAX] = { };
-    unsigned any[PM_TYPE_MAX] = { };
+    unsigned src[PM_TYPE_MAX] = { };
+    unsigned dst[PM_TYPE_MAX] = { };
+    unsigned any[PM_TYPE_MAX] = { };
 
     fp_sum_port_groups(port_tables->ip.src, src);
     fp_sum_port_groups(port_tables->ip.dst, dst);
index f85aebb831cd8dd217b65bdca6fd56b11f89c151..040761fcd1ad233cd127dd06818e38578ffaa59a 100644 (file)
@@ -73,8 +73,8 @@ struct HostApplicationInfo
 {
     HostApplicationInfo() = default;
     HostApplicationInfo(const char *ver, const char *ven);
-    char vendor[INFO_SIZE] = { 0 };
-    char version[INFO_SIZE] = { 0 };
+    char vendor[INFO_SIZE] = { '\0' };
+    char version[INFO_SIZE] = { '\0' };
     bool visibility = true;
 
     friend class HostTracker;
@@ -111,7 +111,7 @@ struct HostApplication
     bool inferred_appid = false;
     uint32_t hits = 0;
     uint32_t last_seen = 0;
-    char user[INFO_SIZE] = { 0 };
+    char user[INFO_SIZE] = { '\0' };
 
     std::vector<HostApplicationInfo, HostAppInfoAllocator> info;
     std::vector<Payload_t, HostCacheAllocIp<Payload_t>> payloads;
@@ -127,7 +127,7 @@ struct HostClient
     HostClient() = default;
     HostClient(AppId clientid, const char *ver, AppId ser);
     AppId id;
-    char version[INFO_SIZE] = { 0 };
+    char version[INFO_SIZE] = { '\0' };
     AppId service;
     std::vector<Payload_t, HostCacheAllocIp<Payload_t>> payloads;
 
@@ -148,7 +148,7 @@ struct DeviceFingerprint
     uint32_t fpid;
     uint32_t fp_type;
     bool jail_broken;
-    char device[INFO_SIZE] = { 0 };
+    char device[INFO_SIZE] = { '\0' };
 };
 
 enum HostType : std::uint32_t
index d585bf189ae0b3794064b992fbac7f8dfc022667..aa4b9f2a8d7b81fa6e609efb0fc5d3799fdbde4f 100644 (file)
@@ -807,7 +807,7 @@ void SnortConfig::set_tunnel_verdicts(const char* args)
     char* tmp, * tok;
 
     tmp = snort_strdup(args);
-    char* lasts = { nullptr };
+    char* lasts = nullptr;
     tok = strtok_r(tmp, " ,", &lasts);
 
     while (tok)
index 8034d61a78bdc059853c91a995703dc01ef5fc7e..9d625a9fcb6ebc9b1705b0efe266e1128caf928e 100644 (file)
@@ -110,7 +110,7 @@ void AppIdDebug::activate(const uint32_t* ip1, const uint32_t* ip2, uint16_t por
     snort_inet_ntop(af, &sip->u6_addr32[(af == AF_INET)? 3 : 0], sipstr, sizeof(sipstr));
     snort_inet_ntop(af, &dip->u6_addr32[(af == AF_INET)? 3 : 0], dipstr, sizeof(dipstr));
 
-    char gr_buf[32] = {0};
+    char gr_buf[32] = { '\0' };
     if (inter_group_flow)
         snprintf(gr_buf, sizeof(gr_buf), " GR=%hd-%hd", sgroup, dgroup);
 
index ef5333cc32c41fde537cdbee113b1b4aed4ba2c4..fff88a14d64b71671a5cc9114f71825c94a7d408 100644 (file)
@@ -176,7 +176,7 @@ protected:
     // functions in tp_appid_utils.cc are static. Thus the public
     // set_field() functions in AppIdHttpSession. We do need set functions
     // for this array, as old pointers need to be deleted upon set().
-    const std::string* meta_data[NUM_METADATA_FIELDS] = { };
+    const std::string* meta_data[NUM_METADATA_FIELDS] = { };
     pair_t meta_offset[NUM_HTTP_FIELDS];
 
     bool is_webdav = false;
@@ -189,8 +189,8 @@ protected:
     int num_matches = 0;
     int num_scans = 0;
     bool skip_simple_detect = false;
-    int ptype_req_counts[NUM_HTTP_FIELDS] = { };
-    int ptype_scan_counts[NUM_HTTP_FIELDS] = { };
+    int ptype_req_counts[NUM_HTTP_FIELDS] = { };
+    int ptype_scan_counts[NUM_HTTP_FIELDS] = { };
     const TunnelDest* tun_dest = nullptr;
 #if RESPONSE_CODE_PACKET_THRESHHOLD
     unsigned response_code_packets = 0;
index 1f89557debfeaa4050f50bceb16d6141a225880b..2c0219abe5d1763c727f6d4b2485b0a96d781a2b 100644 (file)
@@ -60,11 +60,11 @@ public:
     class AppIdDynamicPeg
     {
     public:
-        PegCount stats[DetectorPegs::NUM_APPID_DETECTOR_PEGS] = { };
+        PegCount stats[DetectorPegs::NUM_APPID_DETECTOR_PEGS] = { };
 
         bool all_zeros()
         {
-            PegCount zeroed_peg[DetectorPegs::NUM_APPID_DETECTOR_PEGS] = { };
+            PegCount zeroed_peg[DetectorPegs::NUM_APPID_DETECTOR_PEGS] = { };
             return !memcmp(stats, &zeroed_peg, sizeof(stats));
         }
 
index 4fd863f42d1a8b34922f5bf43dd5027477a660c7..d719876af69dfd5894b97d19124d9284e773faef 100644 (file)
@@ -573,7 +573,7 @@ int ImapClientDetector::validate(AppIdDiscoveryArgs& args)
 {
     const uint8_t* s = args.data;
     const uint8_t* end = (args.data + args.size);
-    char tag[IMAP_TAG_MAX_LEN + 1] = { 0 };
+    char tag[IMAP_TAG_MAX_LEN + 1] = { '\0' };
 
 #ifdef APP_ID_USES_REASSEMBLED
     Stream::flush_response_flush(pkt);
index cfeae4fe02bf576fedf04689ac3e23c264c22b6f..2d82498fbe24b5351755bbfe1970834618e9f11f 100644 (file)
@@ -114,8 +114,8 @@ private:
     PatternService* service_port_pattern = nullptr;
     snort::SearchTool* tcp_pattern_matcher = nullptr;
     snort::SearchTool* udp_pattern_matcher = nullptr;
-    snort::SearchTool* tcp_port_pattern_tree[65536] = { nullptr };
-    snort::SearchTool* udp_port_pattern_tree[65536] = { nullptr };
+    snort::SearchTool* tcp_port_pattern_tree[65536] = { };
+    snort::SearchTool* udp_port_pattern_tree[65536] = { };
 };
 
 #endif
index fc289bc7049eec1f3534437c7aba474cbe8218ff..c1f85bdc06b605a767174811de1123a264fadbd4 100644 (file)
@@ -1033,7 +1033,7 @@ static inline const char* continue_buffer_scan(const char* start, const char* en
 void HttpPatternMatchers::identify_user_agent(const char* start, int size, AppId& service_id,
     AppId& client_id, char** version)
 {
-    char temp_ver[MAX_VERSION_SIZE] = { 0 };
+    char temp_ver[MAX_VERSION_SIZE] = { '\0' };
     MatchedPatterns* mp = nullptr;
 
     client_agent_matcher.find_all(start, size, &http_pattern_match, false, (void*)&mp);
index 406a36603c5caa1a21b7041c34e570d3920bfde0..e8691793b640c8a9beb92338e1a171b944ebfb1d 100644 (file)
@@ -229,8 +229,8 @@ public:
     }
 
     HttpFieldIds cur_ptype;
-    const char* buffer[NUM_HTTP_FIELDS] = { nullptr };
-    uint16_t length[NUM_HTTP_FIELDS] = { };
+    const char* buffer[NUM_HTTP_FIELDS] = { };
+    uint16_t length[NUM_HTTP_FIELDS] = { };
     std::list<MatchedCHPAction> chp_matches[NUM_HTTP_FIELDS];
     CHPMatchTally match_tally;
 
index 273a7b5e7ee40d9d8b7de6ae4156d88dab5fea07..dd28e5a29eee0600f62dbeca48da30f91c7fb629 100644 (file)
@@ -278,7 +278,7 @@ void PacketTracer::add_ip_header_info(const Packet& p)
     actual_sip->ntop(sipstr, sizeof(sipstr));
     actual_dip->ntop(dipstr, sizeof(dipstr));
 
-    char gr_buf[32] = {0};
+    char gr_buf[32] = { '\0' };
     if (p.is_inter_group_flow())
         snprintf(gr_buf, sizeof(gr_buf), " GR=%hd-%hd", p.pkth->ingress_group,
             p.pkth->egress_group);
index 49c7ae89d776cc13d7729e4735eb6580a68dad6c..acabff94ed5d48b013566e278a13292a40d99d94 100644 (file)
@@ -48,7 +48,7 @@ using namespace snort;
 #ifdef DEBUG_MSGS
 static inline void rna_logger_message(const RnaLoggerEvent& rle)
 {
-    char macbuf[19] = { 0 };
+    char macbuf[19] = { '\0' };
     if ( rle.mac )
         snprintf(macbuf, 19, "%02X:%02X:%02X:%02X:%02X:%02X",
             rle.mac[0], rle.mac[1], rle.mac[2], rle.mac[3], rle.mac[4], rle.mac[5]);
index 559ab0f3a8b1532984c7f804f756120823716dd7..bbf6beba9226aefd9cb7a8b6c3a1990d082fa5b5 100644 (file)
@@ -55,7 +55,7 @@ void print_conf_client(FTP_CLIENT_PROTO_CONF* config)
         FTPBounce;
         FTPBounce = ftp_bounce_lookup_next(config->bounce_lookup, &ret))
     {
-        char buf[BUF_SIZE + 1] = {0};
+        char buf[BUF_SIZE + 1] = { '\0' };
 
         FTPBounce->ip.ntop(buf, BUF_SIZE);
 
index 304ae196623968a3cbc8acc036026a77973d9a4b..ac21cade16a6c983254605b5d98c33ea687d45da 100644 (file)
@@ -56,7 +56,7 @@ THREAD_LOCAL ProfileStats Http2Module::http2_profile;
 ProfileStats* Http2Module::get_profile() const
 { return &http2_profile; }
 
-THREAD_LOCAL PegCount Http2Module::peg_counts[PEG_COUNT__MAX] = { };
+THREAD_LOCAL PegCount Http2Module::peg_counts[PEG_COUNT__MAX] = { };
 
 bool Http2Module::begin(const char*, int, SnortConfig*)
 {
index 98eba4905773c2b45f5ff60e920986b4db07ab15..0fbf441d90b115bec83c2b5573957822ef5bbe06 100755 (executable)
@@ -171,7 +171,7 @@ THREAD_LOCAL ProfileStats HttpModule::http_profile;
 ProfileStats* HttpModule::get_profile() const
 { return &http_profile; }
 
-THREAD_LOCAL PegCount HttpModule::peg_counts[PEG_COUNT_MAX] = { };
+THREAD_LOCAL PegCount HttpModule::peg_counts[PEG_COUNT_MAX] = { };
 
 bool HttpModule::begin(const char*, int, SnortConfig*)
 {