endif()
if (DAQ_STATIC_MODULES)
list(SORT DAQ_STATIC_MODULES)
- # set(DAQ_STATIC_MODULES ${DAQ_STATIC_MODULES} CACHE INTERNAL "Static DAQ modules")
+ set(DAQ_STATIC_MODULES ${DAQ_STATIC_MODULES} CACHE INTERNAL "Static DAQ modules")
endif()
endif()
{
void setup() override
{
- // FIXIT-RC workaround for CppUTest mem leak detector issue
- MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
tcpc_api = (const ConnectorApi*) tcp_connector;
s_instance = 0;
set_normal_status();
tcpc_api->tterm(connector);
tcpc_api->dtor(connector_common);
tcp_connector->mod_dtor(mod);
- MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
}
};
return;
if ( trace_enabled(detection_trace, TRACE_BUFFER, 5) )
- dump_buffer(cursor.buffer() + pos, cursor.length(), p);
+ dump_buffer(cursor.buffer() + pos, cursor.length(), p);
else if ((pos != cursor_pos) || strcmp(cursor_name, name))
{
cursor_pos = pos;
}
void SnortConfig::release_scratch(int)
-{ s_state.clear(); }
+{
+ scratcher = nullptr;
+ s_state.clear();
+ s_state.shrink_to_fit();
+}
const SnortConfig* SnortConfig::get_conf()
{ return snort_conf; }
int main(int argc, char** argv)
{
- MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
return CommandLineTestRunner::RunAllTests(argc, argv);
}
#include <CppUTest/CommandLineTestRunner.h>
#include <CppUTest/TestHarness.h>
-using namespace std;
using namespace snort;
namespace snort
const size_t hc_item_sz = sizeof(HostCacheIp::Data) + sizeof(HostTracker);
const size_t ht_item_sz = sizeof(HostApplication);
- // room for n host trackers in the cache and m host applications in ht
- const size_t max_size = n * hc_item_sz + m * ht_item_sz;
+ // room for n host trackers in the cache and 2^floor(log2(3))+2^ceil(log2(3))-1 host
+ // applications in ht
+ // FIXIT-L this makes a questionable assumption about the STL vector implementation
+ // that it will double the allocation each time it needs to increase its size, so
+ // going from 2 to 3 will allocate 4 and then release 2, meaning in order to exactly
+ // induce pruning, the max size should be just one <ht_item_sz> short of holding 6
+ const size_t max_size = n * hc_item_sz + 5 * ht_item_sz;
host_cache.set_max_size(max_size);
// insert n empty host trackers:
- for (size_t i=0; i<n; i++)
+ for (size_t i = 0; i < n; i++)
{
memset(hk, 0, 16);
hk[i] = (uint8_t) i;
// insert m host tracker items (host applications) into the most recent
// host tracker
- size_t i = n-1;
+ size_t i = n - 1;
memset(hk, 0, 16);
hk[i] = (uint8_t) i;
ip.set(hk);
auto ht_ptr = host_cache[ip];
CHECK(ht_ptr != nullptr);
- for (size_t port = 0; port+1<m; port++)
+ for (size_t port = 0; port + 1 < m; port++)
CHECK(true == ht_ptr->add_service(port, IpProtocol::TCP, 676, true));
// Insert a new host tracker item. The sequence of operations is this:
- // - host tracker vector is holding 2 * ht_item_sz = 24 and wants to
- // double in size.
- // - the allocator honors the vector's request, allocating 48 bytes and
- // informs the host_cache about the new size, which exceeds max_size now
+ // - host tracker vector is holding 2 * <ht_item_sz> bytes and wants to double in size.
+ // - the allocator honors the vector's request, allocating 4 * <ht_item_sz> bytes and
+ // informs the host_cache about the new size, which exceeds max_size
// - host_cache prunes, removing the least recent host tracker.
- // Since this ht is empty, precisely hc_item_sz = 88 bytes are freed.
- // - the host tracker vector destructor frees up an additional 24 bytes
+ // Since this ht is empty, precisely <hc_item_sz> bytes are freed.
+ // - the host tracker vector destructor frees up an additional 2 * <ht_item_sz> bytes
// that it reallocated.
// Hence, after the next insert, the math is this:
- size_t sz = host_cache.mem_size() + 4*ht_item_sz - hc_item_sz - 2*ht_item_sz;
+ size_t sz = host_cache.mem_size() + 4 * ht_item_sz - hc_item_sz - 2 * ht_item_sz;
CHECK(true == ht_ptr->add_service(m, IpProtocol::TCP, 676, true));
CHECK(sz == host_cache.mem_size());
res = host_cache.remove(ip, ht_ptr);
CHECK(res == true);
CHECK(ht_ptr != nullptr);
-
}
int main(int argc, char** argv)
{
- // Use this if you want to turn off memory checks entirely:
+ // FIXIT-L There is currently no external way to fully release the memory from the global host
+ // cache unordered_map in host_cache.cc
MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
-
return CommandLineTestRunner::RunAllTests(argc, argv);
}
int main(int argc, char** argv)
{
- // Use this if you want to turn off memory checks entirely:
+ // FIXIT-L There is currently no external way to fully release the memory from the global host
+ // cache unordered_map in host_cache.cc
MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
-
return CommandLineTestRunner::RunAllTests(argc, argv);
}
#include "sfip/sf_ip.h"
using namespace snort;
-using namespace std;
// All tests here use the same module since host_cache is global. Creating a local module for each
// test will cause host_cache PegCount testing to be dependent on the order of running these tests.
TEST_GROUP(host_cache_module)
{
- void setup() override
- {
- MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
- }
-
- void teardown() override
- {
- MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
- }
};
static void try_reload_prune(bool is_not_locked)
// This method is a friend of LruCacheSharedMemcap class.
TEST(host_cache_module, misc)
{
- Value size_val((double)2112);
- Parameter size_param = { "size", Parameter::PT_INT, nullptr, nullptr, "cache size" };
const PegInfo* ht_pegs = module.get_pegs();
const PegCount* ht_stats = module.get_counts();
CHECK(ht_stats[4] == 2); // 2 reload_prunes
CHECK(ht_stats[5] == 1); // 1 remove
- size_val.set(&size_param);
-
- // Set up the host_cache max size.
- module.begin("host_cache", 0, nullptr);
- module.set(nullptr, size_val, nullptr);
- module.end("host_cache", 0, nullptr);
-
ht_stats = module.get_counts();
CHECK(ht_stats[0] == 4);
}
int main(int argc, char** argv)
{
+ // FIXIT-L There is currently no external way to fully release the memory from the global host
+ // cache unordered_map in host_cache.cc
+ MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
return CommandLineTestRunner::RunAllTests(argc, argv);
}
int main(int argc, char** argv)
{
+ // FIXIT-L There is currently no external way to fully release the memory from the global host
+ // cache unordered_map in host_cache.cc
MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
return CommandLineTestRunner::RunAllTests(argc, argv);
}
return 0;
}
-void SnortConfig::release_scratch(int) { }
+void SnortConfig::release_scratch(int)
+{
+ scratcher = nullptr;
+ s_state.clear();
+ s_state.shrink_to_fit();
+}
const SnortConfig* SnortConfig::get_conf()
{ return snort_conf; }
int main(int argc, char** argv)
{
- // FIXIT-L cpputest hangs or crashes in the leak detector
- MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
return CommandLineTestRunner::RunAllTests(argc, argv);
}
TEST_GROUP(app_info_table)
{
- void setup() override
- {
- MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
- }
-
void teardown() override
{
app_info_mgr.cleanup_appid_info_table();
- MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
}
};
char test_log[256];
void setup() override
{
- MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
+ mock_init_appid_pegs();
+ SfIp ip;
+ mock_session = new AppIdSession(IpProtocol::TCP, &ip, 1492, dummy_appid_inspector,
+ dummy_appid_inspector.get_ctxt().get_odp_ctxt());
flow = new Flow;
flow->set_flow_data(mock_session);
mock().setDataObject("test_log", "char", test_log);
{
delete flow;
mock().clear();
- MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
+ mock_cleanup_appid_pegs();
+ delete &mock_session->get_api();
+ delete mock_session;
}
};
int main(int argc, char** argv)
{
- mock_init_appid_pegs();
- SfIp ip;
- mock_session = new AppIdSession(IpProtocol::TCP, &ip, 1492, dummy_appid_inspector,
- dummy_appid_inspector.get_ctxt().get_odp_ctxt());
int rc = CommandLineTestRunner::RunAllTests(argc, argv);
- mock_cleanup_appid_pegs();
- delete &mock_session->get_api();
- delete mock_session;
return rc;
}
void setup() override
{
- MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
SfIp ip;
mock_session = new AppIdSession(IpProtocol::TCP, &ip, 1492, dummy_appid_inspector,
dummy_appid_inspector.get_ctxt().get_odp_ctxt());
delete flow;
delete &mock_session->get_api();
delete mock_session;
- MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
}
};
{
void setup() override
{
- MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
flow = new Flow;
SfIp ip;
mock_session = new AppIdSession(IpProtocol::TCP, &ip, 1492, dummy_appid_inspector, stub_odp_ctxt);
delete flow;
mock().clear();
delete appidDebug;
- MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
}
};
#include <CppUTest/CommandLineTestRunner.h>
#include <CppUTest/TestHarness.h>
+
using namespace snort;
namespace snort
{}
AppIdSession::~AppIdSession()
-{}
+{
+ delete &api;
+}
void AppIdSession::set_client_appid_data(AppId, AppidChangeBits&, char*)
{
void Profiler::reset_stats() { }
void Profiler::show_stats() { }
-MemoryContext::MemoryContext(MemoryTracker&) { }
-MemoryContext::~MemoryContext() { }
void memory::MemoryCap::update_allocations(size_t) { }
void memory::MemoryCap::update_deallocations(size_t) { }
unsigned AppIdSession::inspector_id = 0;
THREAD_LOCAL AppIdDebug* appidDebug = nullptr;
-SfIp sfip;
-AppIdSession session(IpProtocol::IP, &sfip, 0, dummy_appid_inspector, stub_odp_ctxt);
-AppIdHttpSession mock_hsession(session, 0);
-
TEST_GROUP(appid_http_session)
{
+ AppIdHttpSession* mock_hsession;
+ AppIdSession* session;
+
void setup() override
{
- MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
+ SfIp sfip;
+ session = new AppIdSession(IpProtocol::IP, &sfip, 0, dummy_appid_inspector, stub_odp_ctxt);
+ mock_hsession = new AppIdHttpSession(*session, 0);
appidDebug = new AppIdDebug();
}
void teardown() override
{
delete appidDebug;
- MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
+ delete mock_hsession;
+ delete session;
}
};
// in appid_http_session.h.
AppidChangeBits change_bits;
- mock_hsession.set_field( (HttpFieldIds)0, new std::string("agent"), change_bits );
- mock_hsession.set_field( (HttpFieldIds)1, new std::string("host"), change_bits );
- mock_hsession.set_field( (HttpFieldIds)2, new std::string("referer"), change_bits );
- mock_hsession.set_field( (HttpFieldIds)3, new std::string("uri"), change_bits );
- mock_hsession.set_field( (HttpFieldIds)4, new std::string("cookie"), change_bits );
- mock_hsession.set_field( (HttpFieldIds)5, new std::string("req_body"), change_bits );
- mock_hsession.set_field( (HttpFieldIds)6, new std::string("content_type"), change_bits );
- mock_hsession.set_field( (HttpFieldIds)7, new std::string("location"), change_bits );
- mock_hsession.set_field( (HttpFieldIds)8, new std::string("rsp_body"), change_bits );
- mock_hsession.set_field( (HttpFieldIds)9, new std::string("via"), change_bits );
- mock_hsession.set_field( (HttpFieldIds)10, new std::string("response_code"), change_bits );
- mock_hsession.set_field( (HttpFieldIds)11, new std::string("server"), change_bits );
- mock_hsession.set_field( (HttpFieldIds)12, new std::string("xww"), change_bits );
- mock_hsession.set_field( (HttpFieldIds)13, new std::string("url"), change_bits );
+ mock_hsession->set_field( (HttpFieldIds)0, new std::string("agent"), change_bits );
+ mock_hsession->set_field( (HttpFieldIds)1, new std::string("host"), change_bits );
+ mock_hsession->set_field( (HttpFieldIds)2, new std::string("referer"), change_bits );
+ mock_hsession->set_field( (HttpFieldIds)3, new std::string("uri"), change_bits );
+ mock_hsession->set_field( (HttpFieldIds)4, new std::string("cookie"), change_bits );
+ mock_hsession->set_field( (HttpFieldIds)5, new std::string("req_body"), change_bits );
+ mock_hsession->set_field( (HttpFieldIds)6, new std::string("content_type"), change_bits );
+ mock_hsession->set_field( (HttpFieldIds)7, new std::string("location"), change_bits );
+ mock_hsession->set_field( (HttpFieldIds)8, new std::string("rsp_body"), change_bits );
+ mock_hsession->set_field( (HttpFieldIds)9, new std::string("via"), change_bits );
+ mock_hsession->set_field( (HttpFieldIds)10, new std::string("response_code"), change_bits );
+ mock_hsession->set_field( (HttpFieldIds)11, new std::string("server"), change_bits );
+ mock_hsession->set_field( (HttpFieldIds)12, new std::string("xww"), change_bits );
+ mock_hsession->set_field( (HttpFieldIds)13, new std::string("url"), change_bits );
const std::string* field;
- field = mock_hsession.get_field(REQ_AGENT_FID);
+ field = mock_hsession->get_field(REQ_AGENT_FID);
STRCMP_EQUAL(field->c_str(), "agent");
- field = mock_hsession.get_field(REQ_HOST_FID);
+ field = mock_hsession->get_field(REQ_HOST_FID);
STRCMP_EQUAL(field->c_str(), "host");
- field = mock_hsession.get_field(REQ_REFERER_FID);
+ field = mock_hsession->get_field(REQ_REFERER_FID);
STRCMP_EQUAL(field->c_str(), "referer");
- field = mock_hsession.get_field(REQ_URI_FID);
+ field = mock_hsession->get_field(REQ_URI_FID);
STRCMP_EQUAL(field->c_str(), "uri");
- field = mock_hsession.get_field(REQ_COOKIE_FID);
+ field = mock_hsession->get_field(REQ_COOKIE_FID);
STRCMP_EQUAL(field->c_str(), "cookie");
- field = mock_hsession.get_field(REQ_BODY_FID);
+ field = mock_hsession->get_field(REQ_BODY_FID);
STRCMP_EQUAL(field->c_str(), "req_body");
- field = mock_hsession.get_field(RSP_CONTENT_TYPE_FID);
+ field = mock_hsession->get_field(RSP_CONTENT_TYPE_FID);
STRCMP_EQUAL(field->c_str(), "content_type");
- field = mock_hsession.get_field(RSP_LOCATION_FID);
+ field = mock_hsession->get_field(RSP_LOCATION_FID);
STRCMP_EQUAL(field->c_str(), "location");
- field = mock_hsession.get_field(RSP_BODY_FID);
+ field = mock_hsession->get_field(RSP_BODY_FID);
STRCMP_EQUAL(field->c_str(), "rsp_body");
- field = mock_hsession.get_field(MISC_VIA_FID);
+ field = mock_hsession->get_field(MISC_VIA_FID);
STRCMP_EQUAL(field->c_str(), "via");
- field = mock_hsession.get_field(MISC_RESP_CODE_FID);
+ field = mock_hsession->get_field(MISC_RESP_CODE_FID);
STRCMP_EQUAL(field->c_str(), "response_code");
- field = mock_hsession.get_field(MISC_SERVER_FID);
+ field = mock_hsession->get_field(MISC_SERVER_FID);
STRCMP_EQUAL(field->c_str(), "server");
- field = mock_hsession.get_field(MISC_XWW_FID);
+ field = mock_hsession->get_field(MISC_XWW_FID);
STRCMP_EQUAL(field->c_str(), "xww");
- field = mock_hsession.get_field(MISC_URL_FID);
+ field = mock_hsession->get_field(MISC_URL_FID);
STRCMP_EQUAL(field->c_str(), "url");
// Detect changes in host, url, user agent, response, and referer fields
SfIp ipv6;
ipv6.set("2001:db8:85a3::8a2e:370:7334");
AppidChangeBits change_bits;
- mock_hsession.set_field(REQ_URI_FID, new std::string("[2001:db8:85a3::8a2e:370:7334]:51413"), change_bits);
- mock_hsession.set_tun_dest();
- tun_dest = mock_hsession.get_tun_dest();
+ mock_hsession->set_field(REQ_URI_FID, new std::string("[2001:db8:85a3::8a2e:370:7334]:51413"), change_bits);
+ mock_hsession->set_tun_dest();
+ tun_dest = mock_hsession->get_tun_dest();
CHECK(tun_dest != nullptr);
CHECK_EQUAL(tun_dest->port, 51413);
CHECK_EQUAL((ipv6 == tun_dest->ip), true);
{
const TunnelDest* tun_dest = nullptr;
AppidChangeBits change_bits;
- mock_hsession.set_field(REQ_URI_FID, new std::string("[2001:db8:85a3::8a2e:370:1234]:51413"), change_bits);
- mock_hsession.set_tun_dest();
- tun_dest = mock_hsession.get_tun_dest();
+ mock_hsession->set_field(REQ_URI_FID, new std::string("[2001:db8:85a3::8a2e:370:1234]:51413"), change_bits);
+ mock_hsession->set_tun_dest();
+ tun_dest = mock_hsession->get_tun_dest();
CHECK(tun_dest != nullptr);
// Testing with bad URL
- mock_hsession.free_tun_dest();
- mock_hsession.set_field(REQ_URI_FID, new std::string("[2001:db8:85a3::8a2e:370:1235]"), change_bits);
- mock_hsession.set_tun_dest();
- tun_dest = mock_hsession.get_tun_dest();
+ mock_hsession->free_tun_dest();
+ mock_hsession->set_field(REQ_URI_FID, new std::string("[2001:db8:85a3::8a2e:370:1235]"), change_bits);
+ mock_hsession->set_tun_dest();
+ tun_dest = mock_hsession->get_tun_dest();
CHECK(tun_dest == nullptr);
}
{
// Testing set_referred_payload_app_id_data
AppidChangeBits change_bits;
- AppIdPegCounts::init_pegs();
AppIdConfig config;
OdpContext odp_ctxt(config, nullptr);
- session.set_service_id(APP_ID_HTTP, odp_ctxt);
- session.scan_flags |= SCAN_HTTP_HOST_URL_FLAG;
- mock_hsession.set_skip_simple_detect(false);
- mock_hsession.set_field( (HttpFieldIds)2, new std::string("referer"), change_bits );
- mock_hsession.process_http_packet(APP_ID_FROM_INITIATOR, change_bits, odp_ctxt.get_http_matchers());
+ session->set_service_id(APP_ID_HTTP, odp_ctxt);
+ session->scan_flags |= SCAN_HTTP_HOST_URL_FLAG;
+ mock_hsession->set_skip_simple_detect(false);
+ mock_hsession->set_field( (HttpFieldIds)2, new std::string("referer"), change_bits );
+ mock_hsession->process_http_packet(APP_ID_FROM_INITIATOR, change_bits, odp_ctxt.get_http_matchers());
// Detect changes in referred appid
CHECK_EQUAL(change_bits.test(APPID_REFERRED_BIT), true);
{
char* snort_strndup(const char* src, size_t dst_size)
{
- return strndup(src, dst_size);
+ char* dup = (char*)snort_calloc(dst_size + 1);
+ strncpy(dup, src, dst_size + 1);
+ return dup;
}
char* snort_strdup(const char* str)
AppIdHttpSession::~AppIdHttpSession()
{
for ( int i = 0; i < NUM_METADATA_FIELDS; i++)
- {
- if ( meta_data[i] )
- delete meta_data[i];
- }
+ delete meta_data[i];
+ if (tun_dest)
+ delete tun_dest;
}
int AppIdHttpSession::process_http_packet(AppidSessionDirection, AppidChangeBits&, HttpPatternMatchers&) { return 0; }
{
AppidChangeBits change_bits;
- MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
SfIp ip;
mock_session = new AppIdSession(IpProtocol::TCP, &ip, 1492, dummy_appid_inspector, odpctxt);
mock_session->set_ss_application_ids(APPID_UT_ID, APPID_UT_ID, APPID_UT_ID,
{
delete &mock_session->get_api();
delete mock_session;
- MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
}
};
#ifndef RNA_PND_H
#define RNA_PND_H
-#include <limits>
+#include <climits>
#include "helpers/discovery_filter.h"
#include "host_tracker/host_tracker.h"
#include "rna_logger.h"
#include "rna_mac_cache.h"
-#define USHRT_MAX std::numeric_limits<unsigned short>::max()
-
enum class TcpPacketType
{
SYN, SYN_ACK, MIDSTREAM
bool Swapper::reload_in_progress = false;
THREAD_LOCAL RnaStats rna_stats;
THREAD_LOCAL ProfileStats rna_perf_stats;
-static std::string message;
static Request mock_request;
const char* luaL_optlstring(lua_State*, int, const char*, size_t*) { return nullptr; }
-void Request::respond(const char* msg, bool, bool)
-{
- message = msg;
-}
Request& get_current_request()
{ return mock_request; }
#include <CppUTest/CommandLineTestRunner.h>
#include <CppUTest/TestHarness.h>
+#include <CppUTestExt/MockSupport.h>
+
+void Request::respond(const char* msg, bool, bool)
+{
+ mock().actualCall("respond").onObject(this).withParameter("msg", msg);
+}
TEST_GROUP(rna_module_test)
{
- void setup() override
- {
- MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
- }
- void teardown() override
- {
- MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
- }
};
TEST(rna_module_test, reload_fingerprint)
{
// When another reload is pending
+ mock().expectOneCall("respond").onObject(&mock_request).withParameter("msg", "== reload pending; retry\n");
Swapper::set_reload_in_progress(true);
reload_fingerprint(nullptr);
Swapper::set_reload_in_progress(false);
- CHECK_TRUE(message == "== reload pending; retry\n");
+ mock().checkExpectations();
// When rna is not configured
+ mock().expectOneCall("respond").onObject(&mock_request).withParameter("msg", "== reload fingerprint failed - rna not enabled\n");
reload_fingerprint(nullptr);
- CHECK_TRUE(message == "== reload fingerprint failed - rna not enabled\n");
+ mock().checkExpectations();
// Reload in progress flag should remain unset at the end
CHECK_FALSE(Swapper::get_reload_in_progress());
+
+ mock().clear();
}
TEST(rna_module_test, push_tcp_fingerprints)
return 0;
}
-void SnortConfig::release_scratch(int) { }
+void SnortConfig::release_scratch(int)
+{
+ scratcher = nullptr;
+ s_state.clear();
+ s_state.shrink_to_fit();
+}
const SnortConfig* SnortConfig::get_conf()
{ return snort_conf; }
void setup() override
{
- // FIXIT-L cpputest hangs or crashes in the leak detector
- MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
CHECK(se_hyperscan);
mod = mpse_api->base.mod_ctor();
hs = mpse_api->ctor(snort_conf, nullptr, &s_agent);
if ( do_cleanup )
scratcher->cleanup(snort_conf);
mpse_api->base.mod_dtor(mod);
- MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
}
};
void setup() override
{
- // FIXIT-L cpputest hangs or crashes in the leak detector
- MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
CHECK(se_hyperscan);
mod = mpse_api->base.mod_ctor();
if ( do_cleanup )
scratcher->cleanup(snort_conf);
mpse_api->base.mod_dtor(mod);
- MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
}
};
int main(int argc, char** argv)
{
+ // FIXIT-L There is currently no external way to fully release the memory from the static
+ // s_scratch vector in hyperscan.cc
+ MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
return CommandLineTestRunner::RunAllTests(argc, argv);
}
delete scm;
s_maps.clear();
+ s_maps.shrink_to_fit();
}
// receive at most max_messages. Zero indicates unlimited.
{
void setup() override
{
- // FIXIT-L workaround for issue with CppUTest memory leak detection
- MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
SideChannelManager::pre_config_init();
-
SCConnectors test_connectors;
PortBitSet test_ports;
{
SideChannelManager::thread_term();
SideChannelManager::term();
- MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
}
};
{
SideChannel* sc = SideChannelManager::get_side_channel(1);
CHECK(sc != nullptr);
-
sc->register_receive_handler(receive_handler);
bool success = sc->process(1);
}
debug_logf(stream_ip_trace, p, "left overlap, truncating new pkt (slide: %d)\n",
- slide);
+ slide);
break;
ft->frag_bytes += newfrag->size;
debug_logf(stream_ip_trace, nullptr, "[#] accumulated bytes on FragTracker %u, count %d\n",
- ft->frag_bytes, ft->fraglist_count);
+ ft->frag_bytes, ft->fraglist_count);
*retFrag = newfrag;
return FRAG_INSERT_OK;
ft->frag_bytes += newfrag->size;
debug_logf(stream_ip_trace, nullptr, "[#] accumulated bytes on FragTracker %u, count %d\n",
- ft->frag_bytes, ft->fraglist_count);
+ ft->frag_bytes, ft->fraglist_count);
*retFrag = newfrag;
return FRAG_INSERT_OK;
drop_old_segment(trs);
}
else
- full_right_overlap_truncate_new(trs);
+ full_right_overlap_truncate_new(trs);
}
// REASSEMBLY_POLICY_LINUX:
drop_old_segment(trs);
}
else
- full_right_overlap_truncate_new(trs);
+ full_right_overlap_truncate_new(trs);
}
// REASSEMBLY_POLICY_HPUX11:
void SegmentOverlapEditor::full_right_overlap_os5(TcpReassemblerState& trs)
{
- full_right_overlap_truncate_new(trs);
+ full_right_overlap_truncate_new(trs);
}
void SegmentOverlapEditor::print(TcpReassemblerState& trs)
TcpSegmentDescriptor::TcpSegmentDescriptor
(snort::Flow* f, snort::Packet* p, uint32_t meta_ack, uint16_t window)
- : flow(f), pkt(ma_pseudo_packet), tcph(&ma_pseudo_tcph),
- packet_number(p->context->packet_number)
+ : flow(f), pkt(ma_pseudo_packet), tcph(&ma_pseudo_tcph),
+ packet_number(p->context->packet_number)
{
// init tcp header fields for meta-ack packet
ma_pseudo_tcph.th_dport = p->ptrs.tcph->raw_src_port();
ma_pseudo_tcph.th_urp = 0;
// init meta-ack Packet fields stream cares about for TCP ack processing
- pkt->flow = p->flow;
+ pkt->flow = p->flow;
pkt->context = p->context;
pkt->dsize = 0;
int main(int argc, char** argv)
{
- //MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
return CommandLineTestRunner::RunAllTests(argc, argv);
}
#if defined(__linux__)
#include <sys/syscall.h>
#endif
+#include <sys/time.h>
#include <unistd.h>
#include <cerrno>