]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2052 in SNORT/snort3 from ~MIALTIZE/snort3:freebsd_osx to master
authorMichael Altizer (mialtize) <mialtize@cisco.com>
Fri, 6 Mar 2020 00:21:31 +0000 (00:21 +0000)
committerMichael Altizer (mialtize) <mialtize@cisco.com>
Fri, 6 Mar 2020 00:21:31 +0000 (00:21 +0000)
Squashed commit of the following:

commit 23b466c713fcf8ffeed1c3c3f07dc04cdf506d4e
Author: Michael Altizer <mialtize@cisco.com>
Date:   Mon Mar 2 10:07:34 2020 -0500

    build: Fix various build issues on FreeBSD and OS X

commit 0dd9359134dc17194fa31f75d65e6f752675c7af
Author: Michael Altizer <mialtize@cisco.com>
Date:   Mon Mar 2 10:07:34 2020 -0500

    build: Fix LibUUID detection on OS X

commit 30ebcc7187ec3127571caaa8d18aa3fb6516170d
Author: Michael Altizer <mialtize@cisco.com>
Date:   Mon Mar 2 10:07:34 2020 -0500

    http_inspect: Properly mock HttpModule::peg_counts in http_transaction_test

23 files changed:
cmake/FindUUID.cmake
cmake/sanity_checks.cmake
src/connectors/file_connector/test/file_connector_module_test.cc
src/connectors/file_connector/test/file_connector_test.cc
src/connectors/tcp_connector/test/tcp_connector_module_test.cc
src/connectors/tcp_connector/test/tcp_connector_test.cc
src/flow/test/ha_test.cc
src/flow/test/session_test.cc
src/host_tracker/test/host_cache_module_test.cc
src/host_tracker/test/host_cache_test.cc
src/ips_options/test/ips_regex_test.cc
src/main/analyzer.cc
src/managers/module_manager.cc
src/network_inspectors/appid/detector_plugins/http_url_patterns.cc
src/network_inspectors/appid/test/appid_mock_definitions.h
src/network_inspectors/appid/test/appid_mock_session.h
src/network_inspectors/appid/test/tp_mock.cc
src/network_inspectors/rna/rna_logger.cc
src/network_inspectors/rna/rna_pnd.cc
src/search_engines/test/hyperscan_test.cc
src/search_engines/test/search_tool_test.cc
src/service_inspectors/http_inspect/test/http_transaction_test.cc
src/service_inspectors/sip/test/sip_splitter_test.h

index b52a315019f261922a4f4871b50514497122d0b7..d8570fba00aea2ef5c320f0d5cdf3d98b1278965 100644 (file)
@@ -1,41 +1,39 @@
 # Find the native UUID include file and library.
 
 find_package(PkgConfig)
-pkg_check_modules(PKG_HINT uuid)
+pkg_check_modules(PC_UUID uuid)
 
-if (APPLE)
-    set(APPLE_UUID_INCLUDE_DIR "/usr/include/uuid")
-    set(UUID_LIBRARY_NAME "System")
+if (PC_UUID_FOUND)
+    set(UUID_LIBRARY_NAME ${PC_UUID_LIBRARIES})
 else()
-    set(APPLE_INCLUDE_DIR "")
     set(UUID_LIBRARY_NAME "uuid")
 endif()
 
 find_path (UUID_INCLUDE_DIR
     NAMES uuid.h
-    HINTS ${UUID_INCLUDE_DIR_HINT} ${PKG_HINT_INCLUDE_DIRS} ${APPLE_UUID_INCLUDE_DIR}
+    HINTS ${UUID_INCLUDE_DIR_HINT} ${PC_UUID_INCLUDEDIR} ${PC_UUID_INCLUDE_DIRS}
+    PATH_SUFFIXES uuid
 )
 
-if (UUID_INCLUDE_DIR)
+if (UUID_LIBRARY_NAME)
     find_library(UUID_LIBRARY
         NAMES ${UUID_LIBRARY_NAME}
-        HINTS ${UUID_LIBRARIES_DIR_HINT} ${PKG_HINT_LIBRARY_DIRS}
+        HINTS ${UUID_LIBRARIES_DIR_HINT} ${PC_UUID_LIBDIR} ${PC_UUID_LIBRARY_DIRS}
     )
+    set(REQUIRED_UUID_LIBRARY "UUID_LIBRARY")
 else()
-    set(UUID_INCLUDE_DIR "")
+    set(REQUIRED_UUID_LIBRARY "")
 endif()
 
-if (UUID_LIBRARY)
-    set(HAVE_UUID "1")
-
-    include(FindPackageHandleStandardArgs)
-
-    find_package_handle_standard_args(UUID
-        UUID_INCLUDE_DIR UUID_LIBRARY
-    )
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(
+    UUID
+    REQUIRED_VARS
+        UUID_INCLUDE_DIR ${REQUIRED_UUID_LIBRARY}
+)
 
-    mark_as_advanced(UUID_INCLUDE_DIR UUID_LIBRARY)
-else()
-    set(UUID_LIBRARY "")
-endif()
+mark_as_advanced(
+    UUID_INCLUDE_DIR
+    UUID_LIBRARY
+)
 
index 7060eaf4714f61aaa5dbde582b20aea06f5ac6b4..de43a4bb0515d337cd28dbd1053a6cf66010a7b7 100644 (file)
@@ -153,3 +153,7 @@ endif()
 if (SAFEC_FOUND)
     check_library_exists (${SAFEC_LIBRARIES} printf_s "" HAVE_SAFEC)
 endif()
+
+if (UUID_FOUND)
+    check_library_exists ("${UUID_LIBRARY}" uuid_parse "" HAVE_UUID)
+endif()
index 6b9696b41f65df05367997fda97b36a8ed5d8f11..6a1605609156124b850d9c710cd057efaae5d339 100644 (file)
@@ -47,15 +47,6 @@ char* snort_strdup(const char* s)
 
 TEST_GROUP(file_connector_module)
 {
-    void setup() override
-    {
-        MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
-    }
-
-    void teardown() override
-    {
-        MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
-    }
 };
 
 TEST(file_connector_module, test)
index 45e663483dacd027249f91b15ebbc1c6f9fe14b2..cc7be66a24d8288a12a97e97d91d70ef9029de3e 100644 (file)
@@ -34,7 +34,7 @@
 using namespace snort;
 
 extern const BaseApi* file_connector;
-ConnectorApi* fc_api = nullptr;
+const ConnectorApi* fc_api = nullptr;
 
 FileConnectorConfig connector_tx_text_config;
 FileConnectorConfig connector_rx_text_config;
@@ -86,9 +86,7 @@ TEST_GROUP(file_connector)
 {
     void setup() override
     {
-        // FIXIT-RC workaround for CppUTest mem leak detector issue
-        MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
-        fc_api = (ConnectorApi*)file_connector;
+        fc_api = (const ConnectorApi*) file_connector;
         connector_tx_text_config.direction = Connector::CONN_TRANSMIT;
         connector_tx_text_config.connector_name = "tx_t";
         connector_tx_text_config.name = "tx_t";
@@ -106,11 +104,6 @@ TEST_GROUP(file_connector)
         connector_rx_binary_config.name = "rx_t";
         connector_rx_binary_config.text_format = false;
     }
-
-    void teardown() override
-    {
-        MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
-    }
 };
 
 TEST(file_connector, mod_ctor_dtor)
@@ -136,9 +129,7 @@ TEST_GROUP(file_connector_tinit_tterm)
 {
     void setup() override
     {
-        // FIXIT-RC workaround for CppUTest mem leak detector issue
-        MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
-        fc_api = (ConnectorApi*)file_connector;
+        fc_api = (const ConnectorApi*) file_connector;
         connector_tx_text_config.direction = Connector::CONN_TRANSMIT;
         connector_tx_text_config.connector_name = "tx_t";
         connector_tx_text_config.name = "tx_t";
@@ -178,7 +169,6 @@ TEST_GROUP(file_connector_tinit_tterm)
         fc_api->tterm(connector_rb);
         fc_api->dtor(connector_common);
         file_connector->mod_dtor(mod);
-        MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
     }
 };
 
@@ -198,9 +188,7 @@ TEST_GROUP(file_connector_text)
 {
     void setup() override
     {
-        // FIXIT-RC workaround for CppUTest mem leak detector issue
-        MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
-        fc_api = (ConnectorApi*)file_connector;
+        fc_api = (const ConnectorApi*) file_connector;
         connector_tx_text_config.direction = Connector::CONN_TRANSMIT;
         connector_tx_text_config.connector_name = "tx_t";
         connector_tx_text_config.name = "tx_t";
@@ -211,11 +199,6 @@ TEST_GROUP(file_connector_text)
         connector_rx_text_config.text_format = true;
         CHECK(file_connector != nullptr);
     }
-
-    void teardown() override
-    {
-        MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
-    }
 };
 
 TEST(file_connector_text, alloc_transmit_rename_receive_discard)
@@ -264,9 +247,7 @@ TEST_GROUP(file_connector_binary)
 {
     void setup() override
     {
-        // FIXIT-RC workaround for CppUTest mem leak detector issue
-        MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
-        fc_api = (ConnectorApi*)file_connector;
+        fc_api = (const ConnectorApi*) file_connector;
         connector_tx_binary_config.direction = Connector::CONN_TRANSMIT;
         connector_tx_binary_config.connector_name = "tx_b";
         connector_tx_binary_config.name = "tx_b";
@@ -277,11 +258,6 @@ TEST_GROUP(file_connector_binary)
         connector_rx_binary_config.text_format = false;
         CHECK(file_connector != nullptr);
     }
-
-    void teardown() override
-    {
-        MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
-    }
 };
 
 TEST(file_connector_binary, alloc_transmit_rename_receive_discard)
@@ -328,13 +304,6 @@ TEST(file_connector_binary, alloc_transmit_rename_receive_discard)
 
 TEST_GROUP(file_connector_msg_handle)
 {
-    void setup() override
-    {
-    }
-
-    void teardown() override
-    {
-    }
 };
 
 TEST(file_connector_msg_handle, test)
index bd6780541f6078e1bda49b4e7ac20a17cc7ca43e..0f94e0b58f4ab8a7a3e2ff86160b3d833939330c 100644 (file)
@@ -47,15 +47,6 @@ char* snort_strdup(const char* s)
 
 TEST_GROUP(tcp_connector_module)
 {
-    void setup() override
-    {
-        MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
-    }
-
-    void teardown() override
-    {
-        MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
-    }
 };
 
 TEST(tcp_connector_module, test_call)
index 51f4abfb5b98c04d3de3d5307e27d6f2462bd965..454effd24a009fab14c98992c1d162ed672e0e3d 100644 (file)
@@ -39,7 +39,7 @@
 using namespace snort;
 
 extern const BaseApi* tcp_connector;
-ConnectorApi* tcpc_api = nullptr;
+const ConnectorApi* tcpc_api = nullptr;
 
 static unsigned s_instance = 0;
 static unsigned char* s_rec_message = nullptr;
@@ -196,9 +196,7 @@ TEST_GROUP(tcp_connector)
 {
     void setup() override
     {
-        // FIXIT-RC workaround for CppUTest mem leak detector issue
-        //MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
-        tcpc_api = (ConnectorApi*)tcp_connector;
+        tcpc_api = (const ConnectorApi*) tcp_connector;
         connector_config.direction = Connector::CONN_DUPLEX;
         connector_config.connector_name = "tcp";
         connector_config.address = "127.0.0.1";
@@ -206,11 +204,6 @@ TEST_GROUP(tcp_connector)
         connector_config.setup = TcpConnectorConfig::Setup::CALL;
         connector_config.async_receive = false;
     }
-
-    void teardown() override
-    {
-        //MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
-    }
 };
 
 TEST(tcp_connector, mod_ctor_dtor)
@@ -236,9 +229,7 @@ TEST_GROUP(tcp_connector_call_error)
 {
     void setup() override
     {
-        // FIXIT-RC workaround for CppUTest mem leak detector issue
-        //MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
-        tcpc_api = (ConnectorApi*)tcp_connector;
+        tcpc_api = (const ConnectorApi*) tcp_connector;
         set_normal_status();
         connector_config.direction = Connector::CONN_DUPLEX;
         connector_config.connector_name = "tcp";
@@ -259,31 +250,18 @@ TEST_GROUP(tcp_connector_call_error)
         CHECK(connector == nullptr);
         tcpc_api->dtor(connector_common);
         tcp_connector->mod_dtor(mod);
-        //MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
     }
 };
 
 TEST_GROUP(tcp_connector_call_other)
 {
-    void setup() override
-    {
-        // FIXIT-RC workaround for CppUTest mem leak detector issue
-        //MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
-    }
-
-    void teardown() override
-    {
-        //MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
-    }
 };
 
 TEST_GROUP(tcp_connector_answer_error)
 {
     void setup() override
     {
-        // FIXIT-RC workaround for CppUTest mem leak detector issue
-        //MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
-        tcpc_api = (ConnectorApi*)tcp_connector;
+        tcpc_api = (const ConnectorApi*) tcp_connector;
         set_normal_status();
         connector_config.direction = Connector::CONN_DUPLEX;
         connector_config.connector_name = "tcp-a";
@@ -304,7 +282,6 @@ TEST_GROUP(tcp_connector_answer_error)
         tcpc_api->tterm(connector);
         tcpc_api->dtor(connector_common);
         tcp_connector->mod_dtor(mod);
-        //MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
     }
 };
 
@@ -345,7 +322,7 @@ TEST(tcp_connector_answer_error, bad_accept)
 
 TEST(tcp_connector_call_other, bad_setup)
 {
-    tcpc_api = (ConnectorApi*)tcp_connector;
+    tcpc_api = (const ConnectorApi*) tcp_connector;
     s_instance = 0;
     set_normal_status();
     connector_config.direction = Connector::CONN_DUPLEX;
@@ -370,8 +347,8 @@ TEST_GROUP(tcp_connector_tinit_tterm_thread_call)
     void setup() override
     {
         // FIXIT-RC workaround for CppUTest mem leak detector issue
-        //MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
-        tcpc_api = (ConnectorApi*)tcp_connector;
+        MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
+        tcpc_api = (const ConnectorApi*) tcp_connector;
         s_instance = 0;
         set_normal_status();
         connector_config.direction = Connector::CONN_DUPLEX;
@@ -395,7 +372,7 @@ TEST_GROUP(tcp_connector_tinit_tterm_thread_call)
         tcpc_api->tterm(connector);
         tcpc_api->dtor(connector_common);
         tcp_connector->mod_dtor(mod);
-        //MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
+        MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
     }
 };
 
@@ -403,9 +380,7 @@ TEST_GROUP(tcp_connector_tinit_tterm_call)
 {
     void setup() override
     {
-        // FIXIT-RC workaround for CppUTest mem leak detector issue
-        //MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
-        tcpc_api = (ConnectorApi*)tcp_connector;
+        tcpc_api = (const ConnectorApi*) tcp_connector;
         s_instance = 0;
         set_normal_status();
         connector_config.direction = Connector::CONN_DUPLEX;
@@ -429,7 +404,6 @@ TEST_GROUP(tcp_connector_tinit_tterm_call)
         tcpc_api->tterm(connector);
         tcpc_api->dtor(connector_common);
         tcp_connector->mod_dtor(mod);
-        //MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
     }
 };
 
@@ -437,9 +411,7 @@ TEST_GROUP(tcp_connector_no_tinit_tterm_call)
 {
     void setup() override
     {
-        // FIXIT-RC workaround for CppUTest mem leak detector issue
-        //MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
-        tcpc_api = (ConnectorApi*)tcp_connector;
+        tcpc_api = (const ConnectorApi*) tcp_connector;
         s_instance = 0;
         set_normal_status();
         connector_config.direction = Connector::CONN_DUPLEX;
@@ -460,7 +432,6 @@ TEST_GROUP(tcp_connector_no_tinit_tterm_call)
         tcpc_api->tterm(connector);
         tcpc_api->dtor(connector_common);
         tcp_connector->mod_dtor(mod);
-        //MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
     }
 };
 
@@ -514,11 +485,9 @@ TEST_GROUP(tcp_connector_tinit_tterm_answer)
 {
     void setup() override
     {
-        // FIXIT-RC workaround for CppUTest mem leak detector issue
-        //MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
         s_instance = 0;
         set_normal_status();
-        tcpc_api = (ConnectorApi*)tcp_connector;
+        tcpc_api = (const ConnectorApi*) tcp_connector;
         connector_config.direction = Connector::CONN_DUPLEX;
         connector_config.connector_name = "tcp-a";
         connector_config.base_port = 20000;
@@ -539,7 +508,6 @@ TEST_GROUP(tcp_connector_tinit_tterm_answer)
         tcpc_api->tterm(connector);
         tcpc_api->dtor(connector_common);
         tcp_connector->mod_dtor(mod);
-        //MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
     }
 };
 
@@ -785,13 +753,6 @@ TEST(tcp_connector_no_tinit_tterm_call, receive_recv_body_closed)
 
 TEST_GROUP(tcp_connector_msg_handle)
 {
-    void setup() override
-    {
-    }
-
-    void teardown() override
-    {
-    }
 };
 
 TEST(tcp_connector_msg_handle, test)
@@ -803,7 +764,6 @@ TEST(tcp_connector_msg_handle, test)
 
 int main(int argc, char** argv)
 {
-    MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
     int return_value = CommandLineTestRunner::RunAllTests(argc, argv);
     return return_value;
 }
index 63a3544079d274de9f50bce882762407d593591e..f49e971ae7fc0a3de18f35c31eed9a9454b20a02 100644 (file)
@@ -82,7 +82,7 @@ static struct __attribute__((__packed__)) TestUpdateMessage {
         0,
         10
     },
-    0, 1, 2, 3, 4, 5, 6, 7, 8, 9
+    { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }
 };
 
 
@@ -315,8 +315,6 @@ TEST(high_availability_manager_test, inst_init_term)
 
 TEST_GROUP(flow_ha_state_test)
 {
-    void setup() override { }
-    void teardown() override { }
 };
 
 TEST(flow_ha_state_test, timing_test)
index aa5d286335e01f7f3bfbf3b0fa1954055e103ef7..29593a12b94468c0a46a6241d7e44468210e908c 100644 (file)
@@ -35,7 +35,7 @@ class DummySession : public Session
     public:
         DummySession(Flow* f) : Session(f) { }
         void clear() override { }
-        ~DummySession() { }
+        ~DummySession() override = default;
 };
 
 //-------------------------------------------------------------------------
index cdf88c939c826811de49b4404d200f8e8b04e397..4f1a5a94ab45970d050492e4a55225e5252cad42 100644 (file)
@@ -89,7 +89,7 @@ TEST_GROUP(host_cache_module)
     }
 };
 
-void try_reload_prune(bool is_not_locked)
+static void try_reload_prune(bool is_not_locked)
 {
     if ( is_not_locked )
     {
index cad83895f6dc43a1e06dd0ca4b6a1a52a1963994..475da07630445b293303d26691a46f2bba5ae17f 100644 (file)
@@ -67,9 +67,6 @@ TEST(host_cache, hash_test)
 
 int main(int argc, char** argv)
 {
-    //  Use this if you want to turn off memory checks entirely:
-    // MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
-
     return CommandLineTestRunner::RunAllTests(argc, argv);
 }
 
index eaf35ba764c0e279d52efa4f5581a35f39c927e4..b3d5e45da5443ac3e8b65259604c99645c8dccdb 100644 (file)
@@ -134,7 +134,7 @@ static IpsOption* get_option(Module* mod, const char* pat, bool relative = false
     }
     mod->end(ips_regex->name, 0, nullptr);
 
-    IpsApi* api = (IpsApi*)ips_regex;
+    const IpsApi* api = (const IpsApi*) ips_regex;
     IpsOption* opt = api->ctor(mod, nullptr);
 
     return opt;
@@ -164,7 +164,7 @@ TEST(ips_regex_base, base)
 
 TEST(ips_regex_base, ips_option)
 {
-    const IpsApi* ips_api = (IpsApi*)ips_regex;
+    const IpsApi* ips_api = (const IpsApi*) ips_regex;
 
     CHECK(ips_api->ctor);
     CHECK(ips_api->dtor);
@@ -280,7 +280,7 @@ TEST_GROUP(ips_regex_option)
     }
     void teardown() override
     {
-        IpsApi* api = (IpsApi*)ips_regex;
+        const IpsApi* api = (const IpsApi*) ips_regex;
         api->dtor(opt);
         if ( do_cleanup )
             scratcher->cleanup(snort_conf);
@@ -299,7 +299,7 @@ TEST(ips_regex_option, hash)
 
     do_cleanup = scratcher->setup(snort_conf);
 
-    IpsApi* api = (IpsApi*)ips_regex;
+    const IpsApi* api = (const IpsApi*) ips_regex;
     api->dtor(opt2);
 }
 
@@ -310,7 +310,7 @@ TEST(ips_regex_option, opeq)
 
     do_cleanup = scratcher->setup(snort_conf);
 
-    IpsApi* api = (IpsApi*)ips_regex;
+    const IpsApi* api = (const IpsApi*) ips_regex;
     api->dtor(opt2);
 }
 
@@ -319,12 +319,12 @@ TEST(ips_regex_option, match_absolute)
     do_cleanup = scratcher->setup(snort_conf);
 
     Packet pkt;
-    pkt.data = (uint8_t*)"* foo stew *";
-    pkt.dsize = strlen((char*)pkt.data);
+    pkt.data = (const uint8_t*) "* foo stew *";
+    pkt.dsize = strlen((const char*) pkt.data);
 
     Cursor c(&pkt);
     CHECK(opt->eval(c, &pkt) == IpsOption::MATCH);
-    CHECK(!strcmp((char*)c.start(), " stew *"));
+    CHECK(!strcmp((const char*) c.start(), " stew *"));
     CHECK(opt->retry(c));
 }
 
@@ -333,8 +333,8 @@ TEST(ips_regex_option, no_match_delta)
     do_cleanup = scratcher->setup(snort_conf);
 
     Packet pkt;
-    pkt.data = (uint8_t*)"* foo stew *";
-    pkt.dsize = strlen((char*)pkt.data);
+    pkt.data = (const uint8_t*) "* foo stew *";
+    pkt.dsize = strlen((const char*) pkt.data);
 
     Cursor c(&pkt);
     c.set_delta(3);
@@ -359,7 +359,7 @@ TEST_GROUP(ips_regex_option_relative)
     }
     void teardown() override
     {
-        IpsApi* api = (IpsApi*)ips_regex;
+        const IpsApi* api = (const IpsApi*) ips_regex;
         api->dtor(opt);
         if ( do_cleanup )
             scratcher->cleanup(snort_conf);
@@ -372,8 +372,8 @@ TEST(ips_regex_option_relative, no_match)
     do_cleanup = scratcher->setup(snort_conf);
 
     Packet pkt;
-    pkt.data = (uint8_t*)"* foo stew *";
-    pkt.dsize = strlen((char*)pkt.data);
+    pkt.data = (const uint8_t*)"* foo stew *";
+    pkt.dsize = strlen((const char*) pkt.data);
 
     Cursor c(&pkt);
     c.add_pos(3);
index 922f5440933f442923d465931771253bb58060cd..273f91ff1f5893927d25132a3ac8113566be5057 100644 (file)
@@ -95,7 +95,7 @@ public:
     RetryQueue(unsigned interval_ms)
     {
         assert(interval_ms > 0);
-        interval = { interval_ms / 1000, (interval_ms % 1000) * 1000 };
+        interval = { interval_ms / 1000, static_cast<suseconds_t>((interval_ms % 1000) * 1000) };
     }
 
     ~RetryQueue()
@@ -545,7 +545,7 @@ void Analyzer::idle()
     struct timeval now, increment;
     unsigned int timeout = SnortConfig::get_conf()->daq_config->timeout;
     packet_gettimeofday(&now);
-    increment = { timeout / 1000, (timeout % 1000) * 1000 };
+    increment = { timeout / 1000, static_cast<suseconds_t>((timeout % 1000) * 1000) };
     timeradd(&now, &increment, &now);
     packet_time_update(&now);
 
index 33e91d8ed08a65689a1d2a6de8f9725c7e1f3647..25a43605adc50f929eb4361c8e5b8649d93066ef 100644 (file)
@@ -1516,7 +1516,7 @@ struct RulePtr
 
     RulePtr(const Module* m, const RuleMap* r) : mod(m), rule(r) { }
 
-    bool operator< (RulePtr& rhs) const
+    bool operator< (const RulePtr& rhs) const
     {
         if ( mod->get_gid() != rhs.mod->get_gid() )
             return mod->get_gid() < rhs.mod->get_gid();
index 46ec183120c4c6039575b4a491116e131d923fa8..9b8d74eb47477506ea596bb44d722e4a05f5bcd9 100644 (file)
@@ -1622,7 +1622,7 @@ bool HttpPatternMatchers::get_appid_from_url(const char* host, const char* url,
         path = url + host_len;
     }
 
-    patterns[0].pattern = (uint8_t*)host;
+    patterns[0].pattern = (const uint8_t*)host;
     patterns[0].patternSize = host_len;
     patterns[1].pattern = (const uint8_t*)path;
     patterns[1].patternSize = path_len;
index 25bde7e2f5592a2bfec4fed858fa1e8a7e99b0d9..41023d0e96b872c9aea36d52f8e0956719fcd910 100644 (file)
@@ -24,7 +24,7 @@
 #include "service_inspectors/http_inspect/http_msg_header.h"
 
 class Inspector;
-struct ThirdPartyAppIdContext;
+class ThirdPartyAppIdContext;
 
 ThirdPartyAppIdContext* tp_appid_ctxt = nullptr;
 
@@ -120,20 +120,20 @@ void ServiceDiscoveryState::set_service_id_valid(ServiceDetector*) { }
 // Stubs for service_plugins/service_discovery.h
 int ServiceDiscovery::incompatible_data(AppIdSession&, const Packet*, AppidSessionDirection, ServiceDetector*)
 {
-  return 0;
+    return 0;
 }
 
 int ServiceDiscovery::fail_service(AppIdSession&, const Packet*, AppidSessionDirection, ServiceDetector*, ServiceDiscoveryState*)
 {
-  return 0;
+    return 0;
 }
 
-void mock_init_appid_pegs()
+inline void mock_init_appid_pegs()
 {
     AppIdPegCounts::init_pegs();
 }
 
-void mock_cleanup_appid_pegs()
+inline void mock_cleanup_appid_pegs()
 {
     AppIdPegCounts::cleanup_pegs();
     AppIdPegCounts::cleanup_peg_info();
index ce21a9bba2959b4b996e055e3a4edb26f4f4d478..c42e5e785c7026c94fed504ae93850879b671767 100644 (file)
@@ -62,7 +62,7 @@ class MockAppIdDnsSession : public AppIdDnsSession
 public:
     MockAppIdDnsSession()
     {
-        host = (char*)APPID_ID_UT_DNS_HOST;
+        host = (const char*) APPID_ID_UT_DNS_HOST;
         host_offset = APPID_UT_DNS_HOST_OFFSET;
         record_type = APPID_UT_DNS_PATTERN_CNAME_REC;
         response_type = APPID_UT_DNS_NOERROR;
index 77db97e8d7b10a709943a6d7e81bd55a029fc14d..8ed7b86bbd165cb44e9790f0cc1a75bb8b4bd8d6 100644 (file)
@@ -48,7 +48,7 @@ public:
         cerr << WhereMacro << endl;
     }
 
-    ~ThirdPartyAppIdContextImpl()
+    ~ThirdPartyAppIdContextImpl() override
     {
         cerr << WhereMacro << endl;
     }
index 5a72a88a6e5913676950be5e059f9b44bf197cfb..4dc82481d467584ba9c71acffb07f9bb06dce663 100644 (file)
 #include "catch/snort_catch.h"
 #endif
 
+// FIXIT-M workaround for OS X, logger should be using sfip anyway
+#ifndef s6_addr32
+#define s6_addr32 __u6_addr.__u6_addr32
+#endif
+
 using namespace snort;
 
 bool RnaLogger::log(uint16_t type, uint16_t subtype, const Packet* p, RnaTracker* ht,
index 3c08ceb37a2eba1fdbccad5f89875f791399f643..991f4069c6dd09404296555f8d62a3c91cab287c 100644 (file)
@@ -70,7 +70,9 @@ static inline bool is_eligible_udp(const Packet* p)
     {
         const SfIp* src = p->ptrs.ip_api.get_src();
         const SfIp* dst = p->ptrs.ip_api.get_dst();
-        if ( !src->is_set() and IN6_IS_ADDR_MULTICAST(dst->get_ip6_ptr()) and
+        // FIXIT-M this code checking the v6 address unconditionally is almost certainly wrong,
+        //          especially since it's looking for an IPv4-specific protocol
+        if ( !src->is_set() and ((const uint8_t *) dst->get_ip6_ptr())[0] == 0XFF and
             p->ptrs.sp == 68 and p->ptrs.dp == 67 )
             return false; // skip BOOTP
     }
@@ -135,7 +137,8 @@ void RnaPnd::discover_network_tcp(const Packet* p)
 void RnaPnd::discover_network_udp(const Packet* p)
 {
     const auto& ip_api = p->ptrs.ip_api;
-    if ( IN6_IS_ADDR_MULTICAST(ip_api.get_dst()->get_ip6_ptr()) )
+    // FIXIT-L this used to be IN6_IS_ADDR_MULTICAST(), SfIp should implement something comparable
+    if ( ((const uint8_t *) ip_api.get_dst()->get_ip6_ptr())[0] == 0XFF )
         discover_network(p, 0);
     else
         discover_network(p, ip_api.ttl());
index 36e526c2cb8afd27924d903d3567221e23850813..2146529de9a0e575704973f6cd883f4aa05b52ea 100644 (file)
@@ -193,7 +193,7 @@ TEST(mpse_hs_base, base)
 
 TEST(mpse_hs_base, mpse)
 {
-    const MpseApi* mpse_api = (MpseApi*)se_hyperscan;
+    const MpseApi* mpse_api = (const MpseApi*)se_hyperscan;
     CHECK(mpse_api->flags == (MPSE_REGEX | MPSE_MTBLD));
 
     CHECK(mpse_api->ctor);
@@ -219,7 +219,7 @@ TEST_GROUP(mpse_hs_match)
     Module* mod = nullptr;
     Mpse* hs = nullptr;
     bool do_cleanup = false;
-    const MpseApi* mpse_api = (MpseApi*)se_hyperscan;
+    const MpseApi* mpse_api = (const MpseApi*)se_hyperscan;
 
     void setup() override
     {
@@ -251,7 +251,7 @@ TEST(mpse_hs_match, empty)
     do_cleanup = scratcher->setup(snort_conf);
 
     int state = 0;
-    CHECK(hs->search((uint8_t*)"foo", 3, match, nullptr, &state) == 0);
+    CHECK(hs->search((const uint8_t*)"foo", 3, match, nullptr, &state) == 0);
     CHECK(hits == 0);
 }
 
@@ -259,14 +259,14 @@ TEST(mpse_hs_match, single)
 {
     Mpse::PatternDescriptor desc;
 
-    CHECK(hs->add_pattern(nullptr, (uint8_t*)"foo", 3, desc, s_user) == 0);
+    CHECK(hs->add_pattern(nullptr, (const uint8_t*)"foo", 3, desc, s_user) == 0);
     CHECK(hs->prep_patterns(snort_conf) == 0);
     CHECK(hs->get_pattern_count() == 1);
 
     do_cleanup = scratcher->setup(snort_conf);
 
     int state = 0;
-    CHECK(hs->search((uint8_t*)"foo", 3, match, nullptr, &state) == 1);
+    CHECK(hs->search((const uint8_t*)"foo", 3, match, nullptr, &state) == 1);
     CHECK(hits == 1);
 }
 
@@ -274,15 +274,15 @@ TEST(mpse_hs_match, nocase)
 {
     Mpse::PatternDescriptor desc(true, true, false);
 
-    CHECK(hs->add_pattern(nullptr, (uint8_t*)"foo", 3, desc, s_user) == 0);
+    CHECK(hs->add_pattern(nullptr, (const uint8_t*)"foo", 3, desc, s_user) == 0);
     CHECK(hs->prep_patterns(snort_conf) == 0);
     CHECK(hs->get_pattern_count() == 1);
 
     do_cleanup = scratcher->setup(snort_conf);
 
     int state = 0;
-    CHECK(hs->search((uint8_t*)"foo", 3, match, nullptr, &state) == 1);
-    CHECK(hs->search((uint8_t*)"fOo", 3, match, nullptr, &state) == 1);
+    CHECK(hs->search((const uint8_t*)"foo", 3, match, nullptr, &state) == 1);
+    CHECK(hs->search((const uint8_t*)"fOo", 3, match, nullptr, &state) == 1);
     CHECK(hits == 2);
 }
 
@@ -290,15 +290,15 @@ TEST(mpse_hs_match, other)
 {
     Mpse::PatternDescriptor desc(false, true, false);
 
-    CHECK(hs->add_pattern(nullptr, (uint8_t*)"foo", 3, desc, s_user) == 0);
+    CHECK(hs->add_pattern(nullptr, (const uint8_t*)"foo", 3, desc, s_user) == 0);
     CHECK(hs->prep_patterns(snort_conf) == 0);
     CHECK(hs->get_pattern_count() == 1);
 
     do_cleanup = scratcher->setup(snort_conf);
 
     int state = 0;
-    CHECK(hs->search((uint8_t*)"foo", 3, match, nullptr, &state) == 1);
-    CHECK(hs->search((uint8_t*)"fOo", 3, match, nullptr, &state) == 0);
+    CHECK(hs->search((const uint8_t*)"foo", 3, match, nullptr, &state) == 1);
+    CHECK(hs->search((const uint8_t*)"fOo", 3, match, nullptr, &state) == 0);
     CHECK(hits == 1);
 }
 
@@ -306,9 +306,9 @@ TEST(mpse_hs_match, multi)
 {
     Mpse::PatternDescriptor desc;
 
-    CHECK(hs->add_pattern(nullptr, (uint8_t*)"foo", 3, desc, s_user) == 0);
-    CHECK(hs->add_pattern(nullptr, (uint8_t*)"bar", 3, desc, s_user) == 0);
-    CHECK(hs->add_pattern(nullptr, (uint8_t*)"baz", 3, desc, s_user) == 0);
+    CHECK(hs->add_pattern(nullptr, (const uint8_t*)"foo", 3, desc, s_user) == 0);
+    CHECK(hs->add_pattern(nullptr, (const uint8_t*)"bar", 3, desc, s_user) == 0);
+    CHECK(hs->add_pattern(nullptr, (const uint8_t*)"baz", 3, desc, s_user) == 0);
 
     CHECK(hs->prep_patterns(snort_conf) == 0);
     CHECK(hs->get_pattern_count() == 3);
@@ -316,7 +316,7 @@ TEST(mpse_hs_match, multi)
     do_cleanup = scratcher->setup(snort_conf);
 
     int state = 0;
-    CHECK(hs->search((uint8_t*)"foo bar baz", 11, match, nullptr, &state) == 3);
+    CHECK(hs->search((const uint8_t*)"foo bar baz", 11, match, nullptr, &state) == 3);
     CHECK(hits == 3);
 }
 
@@ -326,7 +326,7 @@ TEST(mpse_hs_match, regex)
     Mpse::PatternDescriptor desc;
 
     CHECK(hs->add_pattern(
-            nullptr, (uint8_t*)"(foo)|(bar)|(baz)", 17, desc, s_user) == 0);
+            nullptr, (const uint8_t*)"(foo)|(bar)|(baz)", 17, desc, s_user) == 0);
 
     CHECK(hs->prep_patterns(snort_conf) == 0);
     CHECK(hs->get_pattern_count() == 1);
@@ -334,7 +334,7 @@ TEST(mpse_hs_match, regex)
     do_cleanup = scratcher->setup(snort_conf);
 
     int state = 0;
-    CHECK(hs->search((uint8_t*)"foo bar baz", 11, match, nullptr, &state) == 0);
+    CHECK(hs->search((const uint8_t*)"foo bar baz", 11, match, nullptr, &state) == 0);
     CHECK(hits == 3);
 }
 
@@ -344,7 +344,7 @@ TEST(mpse_hs_match, pcre)
 
     // from sid 23286
     CHECK(hs->add_pattern(
-            nullptr, (uint8_t*)"\\.definition\\s*\\(", 21, desc, s_user) == 0);
+            nullptr, (const uint8_t*)"\\.definition\\s*\\(", 21, desc, s_user) == 0);
 
     CHECK(hs->prep_patterns(snort_conf) == 0);
     CHECK(hs->get_pattern_count() == 1);
@@ -352,10 +352,10 @@ TEST(mpse_hs_match, pcre)
     do_cleanup = scratcher->setup(snort_conf);
 
     int state = 0;
-    CHECK(hs->search((uint8_t*)":definition(", 12, match, nullptr, &state) == 0);
-    CHECK(hs->search((uint8_t*)".definition(", 12, match, nullptr, &state) == 0);
-    CHECK(hs->search((uint8_t*)".definition (", 13, match, nullptr, &state) == 0);
-    CHECK(hs->search((uint8_t*)".definition\r\n(", 16, match, nullptr, &state) == 0);
+    CHECK(hs->search((const uint8_t*)":definition(", 12, match, nullptr, &state) == 0);
+    CHECK(hs->search((const uint8_t*)".definition(", 12, match, nullptr, &state) == 0);
+    CHECK(hs->search((const uint8_t*)".definition (", 13, match, nullptr, &state) == 0);
+    CHECK(hs->search((const uint8_t*)".definition\r\n(", 16, match, nullptr, &state) == 0);
     CHECK(hits == 4);
 }
 #endif
@@ -370,7 +370,7 @@ TEST_GROUP(mpse_hs_multi)
     Mpse* hs1 = nullptr;
     Mpse* hs2 = nullptr;
     bool do_cleanup = false;
-    const MpseApi* mpse_api = (MpseApi*)se_hyperscan;
+    const MpseApi* mpse_api = (const MpseApi*)se_hyperscan;
 
     void setup() override
     {
@@ -404,8 +404,8 @@ TEST(mpse_hs_multi, single)
 {
     Mpse::PatternDescriptor desc;
 
-    CHECK(hs1->add_pattern(nullptr, (uint8_t*)"uba", 3, desc, s_user) == 0);
-    CHECK(hs2->add_pattern(nullptr, (uint8_t*)"tuba", 4, desc, s_user) == 0);
+    CHECK(hs1->add_pattern(nullptr, (const uint8_t*)"uba", 3, desc, s_user) == 0);
+    CHECK(hs2->add_pattern(nullptr, (const uint8_t*)"tuba", 4, desc, s_user) == 0);
 
     CHECK(hs1->prep_patterns(snort_conf) == 0);
     CHECK(hs2->prep_patterns(snort_conf) == 0);
@@ -416,13 +416,13 @@ TEST(mpse_hs_multi, single)
     do_cleanup = scratcher->setup(snort_conf);
 
     int state = 0;
-    CHECK(hs1->search((uint8_t*)"fubar", 5, match, nullptr, &state) == 1 );
+    CHECK(hs1->search((const uint8_t*)"fubar", 5, match, nullptr, &state) == 1 );
     CHECK(hits == 1);
 
-    CHECK(hs2->search((uint8_t*)"fubar", 5, match, nullptr, &state) == 0);
+    CHECK(hs2->search((const uint8_t*)"fubar", 5, match, nullptr, &state) == 0);
     CHECK(hits == 1);
 
-    CHECK(hs1->search((uint8_t*)"snafu", 5, match, nullptr, &state) == 0);
+    CHECK(hs1->search((const uint8_t*)"snafu", 5, match, nullptr, &state) == 0);
     CHECK(hits == 1);
 }
 
index 056426ac44c5369b1f9a8cd8d302788e773eb2bf..68319c8c091b44c0f06ef6c543947a532b04d163 100644 (file)
@@ -72,7 +72,7 @@ unsigned get_instance_id()
 { return 0; }
 
 void LogValue(const char*, const char*, FILE*) { }
-SO_PUBLIC void LogMessage(const char*, ...) { }
+void LogMessage(const char*, ...) { }
 [[noreturn]] void FatalError(const char*,...) { exit(1); }
 void LogCount(char const*, uint64_t, FILE*) { }
 void LogStat(const char*, double, FILE*) { }
@@ -162,10 +162,10 @@ Mpse* MpseManager::get_search_engine(const char *type)
     const MpseApi* api;
 
     if ( !strcmp(type, "ac_bnfa") )
-        api = (MpseApi*)se_ac_bnfa;
+        api = (const MpseApi*) se_ac_bnfa;
 
     else if ( !strcmp(type, "ac_full") )
-        api = (MpseApi*)se_ac_full;
+        api = (const MpseApi*) se_ac_full;
 
     else
         return nullptr;
index ec3289d1c080d20e969cd7d4c36438e42e7d14ca..89eda0bcb16aa3c1526302d3be0d520919b64308 100644 (file)
@@ -48,7 +48,7 @@ fd_status_t File_Decomp_StopFree(fd_session_t*) { return File_Decomp_OK; }
 size_t str_to_hash(unsigned char const*, size_t) { return 0; }
 }
 
-THREAD_LOCAL PegCount HttpModule::peg_counts[1];
+THREAD_LOCAL PegCount HttpModule::peg_counts[PEG_COUNT_MAX] = { };
 
 class HttpUnitTestSetup
 {
index 6ba5409ce2c9b12faf6c3ceb658777e4179349ef..b51c74b7c8d9886738f2d96ceee4b7a549de8eeb 100644 (file)
@@ -42,7 +42,7 @@ const uint8_t blanks[] = {' ', '\t' };
 class SipSplitterUT
 {
 public:
-    SipSplitterUT(const SipSplitter& ss) : ss(ss) { };
+    SipSplitterUT(const SipSplitter& ss) : ss(ss) { }
 
     bool splitter_is_paf()
     {