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

commit 6a0563a5523807e0f4cf3d7717aa0fc548f5fb14
Author: Michael Altizer <mialtize@cisco.com>
Date:   Tue Jun 30 18:27:57 2020 -0400

    build: Fix unit tests to build and work properly on a 32-bit system

src/helpers/sigsafe.cc
src/host_tracker/test/host_cache_module_test.cc
src/network_inspectors/appid/test/appid_api_test.cc
src/network_inspectors/appid/test/appid_http_session_test.cc
src/payload_injector/test/payload_injector_test.cc
src/pub_sub/test/pub_sub_http_event_test.cc

index 2d273bee3680fde834ce8d946c641a040d2f6142..9978f3a2d39e5fc0d774cd5e2ad87886f4c5e86f 100644 (file)
@@ -38,7 +38,7 @@
 static int sigsafe_format_uint64_dec(uint64_t num, char* buf, size_t buf_len)
 {
     uint64_t divisor;
-    size_t len;
+    size_t len, i;
 
     // ceil(log10(0xFFFFFFFFFFFFFFFF)) = 20 + 1 for '\0'
     if (buf_len > 21)
@@ -48,7 +48,7 @@ static int sigsafe_format_uint64_dec(uint64_t num, char* buf, size_t buf_len)
          len < buf_len - 1 && num / divisor;
          len++, divisor *= 10);
 
-    for (size_t i = len, divisor = 1; i > 0; i--, divisor *= 10)
+    for (i = len, divisor = 1; i > 0; i--, divisor *= 10)
         buf[i - 1] = '0' + ((num / divisor) % 10);
 
     buf[len] = '\0';
@@ -58,7 +58,7 @@ static int sigsafe_format_uint64_dec(uint64_t num, char* buf, size_t buf_len)
 static int sigsafe_format_uint64_hex(uint64_t num, char* buf, size_t buf_len)
 {
     uint64_t divisor;
-    size_t len;
+    size_t len, i;
 
     // log16(0xFFFFFFFFFFFFFFFF) = 16 + 1 for '\0'
     if (buf_len > 17)
@@ -68,7 +68,7 @@ static int sigsafe_format_uint64_hex(uint64_t num, char* buf, size_t buf_len)
          len < buf_len - 1 && num / divisor;
          len++, divisor *= 0x10);
 
-    for (size_t i = len, divisor = 1; i > 0; i--, divisor *= 0x10)
+    for (i = len, divisor = 1; i > 0; i--, divisor *= 0x10)
     {
         int val = (num / divisor) % 0x10;
 
@@ -243,7 +243,7 @@ void SigSafePrinter::hex_dump(const uint8_t* data, unsigned len)
             else if (i % 2 == 0)
                 line[lidx++] = ' ';
         }
-        sigsafe_snprintf(line + lidx, sizeof(line) - lidx, "%02x", data[i]);
+        sigsafe_snprintf(line + lidx, sizeof(line) - lidx, "%02x", (uint64_t) data[i]);
         lidx += 2;
     }
     if (lidx)
index d52141c49bb832dd0bb0a242f2a26aeb4999fb4d..62d145260c70a501d79e5d00ebb8070a80eb29f3 100644 (file)
@@ -99,11 +99,11 @@ static void try_reload_prune(bool is_not_locked)
 {
     if ( is_not_locked )
     {
-        CHECK(host_cache.reload_prune(256, 2) == true);
+        CHECK(host_cache.reload_prune(host_cache.mem_chunk * 1.5, 2) == true);
     }
     else
     {
-        CHECK(host_cache.reload_prune(256, 2) == false);
+        CHECK(host_cache.reload_prune(host_cache.mem_chunk * 1.5, 2) == false);
     }
 }
 
@@ -136,10 +136,10 @@ TEST(host_cache_module, misc)
     CHECK(ht_stats[0] == 3);
 
     // no pruning needed for resizing higher than current size
-    CHECK(host_cache.reload_resize(2048) == false);
+    CHECK(host_cache.reload_resize(host_cache.mem_chunk * 10) == false);
 
     // pruning needed for resizing lower than current size
-    CHECK(host_cache.reload_resize(256) == true);
+    CHECK(host_cache.reload_resize(host_cache.mem_chunk * 1.5) == true);
 
     // pruning in thread is not done when reload_mutex is already locked
     host_cache.reload_mutex.lock();
index 3790cc812b9e12ccbcd79ccf21e338ad3cc431f1..cdaef8c1aa75479be9bd3adce6318fe2ad5e8418 100644 (file)
@@ -78,7 +78,7 @@ void AppIdSession::publish_appid_event(AppidChangeBits& change_bits, Flow* flow,
     DataBus::publish(APPID_EVENT_ANY_CHANGE, app_event, flow);
 }
 
-bool SslPatternMatchers::scan_hostname(unsigned char const* server_name, unsigned long, AppId& client_id, AppId& payload_id)
+bool SslPatternMatchers::scan_hostname(const uint8_t* server_name, size_t, AppId& client_id, AppId& payload_id)
 {
     if (((const char*)server_name) == APPID_UT_TLS_HOST)
     {
@@ -93,7 +93,7 @@ bool SslPatternMatchers::scan_hostname(unsigned char const* server_name, unsigne
     return true;
 }
 
-bool SslPatternMatchers::scan_cname(unsigned char const* cname, unsigned long, AppId& client_id, AppId& payload_id)
+bool SslPatternMatchers::scan_cname(const uint8_t* cname, size_t, AppId& client_id, AppId& payload_id)
 {
     if (((const char*)cname) == APPID_UT_TLS_HOST)
     {
index 6d4646cd8ddbab950b6588053974867c051b2827..b72edd4755c333940b8343f23f6c949bf592b7f1 100644 (file)
@@ -152,8 +152,8 @@ void Profiler::show_stats() { }
 
 MemoryContext::MemoryContext(MemoryTracker&) { }
 MemoryContext::~MemoryContext() { }
-void memory::MemoryCap::update_allocations(unsigned long) { }
-void memory::MemoryCap::update_deallocations(unsigned long) { }
+void memory::MemoryCap::update_allocations(size_t) { }
+void memory::MemoryCap::update_deallocations(size_t) { }
 
 OdpContext::OdpContext(const AppIdConfig&, snort::SnortConfig*) { }
 AppIdConfig::~AppIdConfig() { }
index f072a506f89c1ae1a6a95bd1fd83fc0d13172e66..11b27de16244c974c78e06cbee7f3d96efba3b09 100644 (file)
@@ -40,7 +40,7 @@ using namespace snort;
 //--------------------------------------------------------------------------
 namespace snort
 {
-uint32_t Active::send_data(snort::Packet*, unsigned long, unsigned char const*, unsigned int)
+uint32_t Active::send_data(snort::Packet*, EncodeFlags, unsigned char const*, unsigned int)
 {
     return 1;
 }
index cca033e6e2e71887e1cf688cc9748f533eb0d1a6..7d20bc7a0db07dc8233126ac45603359136d2978 100644 (file)
@@ -37,8 +37,8 @@ using namespace HttpCommon;
 
 // Stubs to make the code link
 const Field Field::FIELD_NULL { STAT_NO_SOURCE };
-const Field& HttpMsgSection::get_classic_buffer(unsigned int, unsigned long, unsigned long)
-    { return Field::FIELD_NULL; }
+const Field& HttpMsgSection::get_classic_buffer(unsigned, uint64_t, uint64_t)
+{ return Field::FIELD_NULL; }
 
 TEST_GROUP(pub_sub_http_event_test)
 {