From: Michael Altizer (mialtize) Date: Tue, 30 Jun 2020 23:39:57 +0000 (+0000) Subject: Merge pull request #2308 in SNORT/snort3 from ~MIALTIZE/snort3:32bit_ut to master X-Git-Tag: 3.0.2-1~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9855c215d87527043c522c038722db6e75bdc133;p=thirdparty%2Fsnort3.git Merge pull request #2308 in SNORT/snort3 from ~MIALTIZE/snort3:32bit_ut to master Squashed commit of the following: commit 6a0563a5523807e0f4cf3d7717aa0fc548f5fb14 Author: Michael Altizer Date: Tue Jun 30 18:27:57 2020 -0400 build: Fix unit tests to build and work properly on a 32-bit system --- diff --git a/src/helpers/sigsafe.cc b/src/helpers/sigsafe.cc index 2d273bee3..9978f3a2d 100644 --- a/src/helpers/sigsafe.cc +++ b/src/helpers/sigsafe.cc @@ -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) diff --git a/src/host_tracker/test/host_cache_module_test.cc b/src/host_tracker/test/host_cache_module_test.cc index d52141c49..62d145260 100644 --- a/src/host_tracker/test/host_cache_module_test.cc +++ b/src/host_tracker/test/host_cache_module_test.cc @@ -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(); diff --git a/src/network_inspectors/appid/test/appid_api_test.cc b/src/network_inspectors/appid/test/appid_api_test.cc index 3790cc812..cdaef8c1a 100644 --- a/src/network_inspectors/appid/test/appid_api_test.cc +++ b/src/network_inspectors/appid/test/appid_api_test.cc @@ -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) { diff --git a/src/network_inspectors/appid/test/appid_http_session_test.cc b/src/network_inspectors/appid/test/appid_http_session_test.cc index 6d4646cd8..b72edd475 100644 --- a/src/network_inspectors/appid/test/appid_http_session_test.cc +++ b/src/network_inspectors/appid/test/appid_http_session_test.cc @@ -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() { } diff --git a/src/payload_injector/test/payload_injector_test.cc b/src/payload_injector/test/payload_injector_test.cc index f072a506f..11b27de16 100644 --- a/src/payload_injector/test/payload_injector_test.cc +++ b/src/payload_injector/test/payload_injector_test.cc @@ -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; } diff --git a/src/pub_sub/test/pub_sub_http_event_test.cc b/src/pub_sub/test/pub_sub_http_event_test.cc index cca033e6e..7d20bc7a0 100644 --- a/src/pub_sub/test/pub_sub_http_event_test.cc +++ b/src/pub_sub/test/pub_sub_http_event_test.cc @@ -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) {