mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-28 06:59:33 +00:00
Fix nedge crash on factory reset and subsequent crash on reloadPrefs
0x00000000004489b2 in Redis::get (this=0x831370,
key=0x574594 "ntopng.user.admin.password",
rsp=0x834c00 "\030\323\037\365\377\177", rsp_len=131052, cache_it=false)
at src/Redis.cpp:259
0x000000000044a9fc in Redis::setDefaults (this=0x831370) at src/Redis.cpp:719
0x000000000044ac0d in Redis::flushDb (this=0x831370) at src/Redis.cpp:757
0x00000000004752e5 in ntop_flush_redis (vm=0x40000378) at src/Lua.cpp:1948
==18227== Invalid free() / delete / delete[] / realloc()
==18227== at 0x4C2E10B: free (vg_replace_malloc.c:530)
==18227== by 0x153431: Prefs::refreshLanWanInterfaces() (Prefs.cpp:1543)
==18227== by 0x15035A: Prefs::reloadPrefsFromRedis() (Prefs.cpp:557)
==18227== by 0x137DA7: Redis::checkDumpable(char const*) (Redis.cpp:206)
This commit is contained in:
parent
3785c6cc19
commit
925c7ea417
5 changed files with 23 additions and 38 deletions
|
|
@ -40,7 +40,7 @@ class Prefs {
|
|||
pcap_direction_t captureDirection;
|
||||
char *deferred_interfaces_to_register[MAX_NUM_INTERFACES], *cli;
|
||||
char *http_binding_address, *https_binding_address;
|
||||
char *lan_interface, *wan_interface;
|
||||
char *lan_interface;
|
||||
Ntop *ntop;
|
||||
bool enable_dns_resolution, sniff_dns_responses,
|
||||
categorization_enabled, resolve_all_host_ip, change_user, daemonize,
|
||||
|
|
@ -231,9 +231,6 @@ class Prefs {
|
|||
void loadInstanceNameDefaults();
|
||||
void registerNetworkInterfaces();
|
||||
void refreshHostsAlertsPrefs();
|
||||
#ifdef HAVE_NEDGE
|
||||
void refreshLanWanInterfaces();
|
||||
#endif
|
||||
|
||||
inline const char* get_http_binding_address() { return(http_binding_address); };
|
||||
inline const char* get_https_binding_address() { return(https_binding_address); };
|
||||
|
|
@ -258,9 +255,9 @@ class Prefs {
|
|||
inline char* get_ls_proto() { return(ls_proto); };
|
||||
inline char* get_zmq_encryption_pwd() { return(zmq_encryption_pwd); };
|
||||
inline char* get_command_line() { return(cli ? cli : (char*)""); };
|
||||
inline char* get_lan_interface() { return(lan_interface ? lan_interface : (char*)""); };
|
||||
inline void set_lan_interface(char *iface) { if(lan_interface) free(lan_interface); lan_interface = strdup(iface); };
|
||||
|
||||
inline char* get_lan_interface() { return(lan_interface ? lan_interface : (char*)""); }
|
||||
inline char* get_wan_interface() { return(wan_interface ? wan_interface : (char*)""); }
|
||||
inline char* getInterfaceAt(int id) { return((id >= MAX_NUM_INTERFACES) ? NULL : ifNames[id].name); };
|
||||
inline bool areMacNdpiStatsEnabled() { return(enable_mac_ndpi_stats); };
|
||||
inline pcap_direction_t getCaptureDirection() { return(captureDirection); }
|
||||
|
|
|
|||
|
|
@ -180,7 +180,6 @@
|
|||
#define DROP_HOST_TRAFFIC "ntopng.prefs.drop_host_traffic"
|
||||
#define DUMP_HOST_TRAFFIC "ntopng.prefs.dump_host_traffic"
|
||||
#define HOST_TRAFFIC_QUOTA "ntopng.prefs.hosts_quota"
|
||||
#define LAN_INTERFACE_NAME "ntopng.prefs.network.lan_if"
|
||||
#define SPLASH_HTTP_PORT "ntopng.prefs.http_splash_port"
|
||||
#define TRAFFIC_FILTERING_CACHE_DURATION 43200 /* 12 h */
|
||||
#define DNS_CACHE_DURATION 3600 /* 1 h */
|
||||
|
|
@ -490,10 +489,6 @@
|
|||
#define CONST_RUNTIME_PREFS_SNMP_PROTO_VERSION "ntopng.prefs.default_snmp_version"
|
||||
#define CONST_RUNTIME_PREFS_IFACE_FLOW_COLLECTION "ntopng.prefs.dynamic_flow_collection_mode" /* {"none", "vlan", "probe_ip","ingress_iface_idx"} */
|
||||
#define CONST_RUNTIME_PREFS_IGNORED_INTERFACES "ntopng.prefs.ignored_interfaces"
|
||||
#ifdef HAVE_NEDGE
|
||||
#define CONST_RUNTIME_PREFS_LAN_INTERFACE "ntopng.prefs.network.lan_if"
|
||||
#define CONST_RUNTIME_PREFS_WAN_INTERFACE "ntopng.prefs.network.wan_if"
|
||||
#endif
|
||||
#define CONST_RUNTIME_PREFS_ENABLE_MAC_NDPI_STATS "ntopng.prefs.l2_device_ndpi_timeseries_creation"
|
||||
#define DISAGGREGATION_PROBE_IP "probe_ip"
|
||||
#define DISAGGREGATION_IFACE_ID "iface_idx"
|
||||
|
|
|
|||
18
src/Lua.cpp
18
src/Lua.cpp
|
|
@ -3620,6 +3620,23 @@ static int ntop_set_lan_ip_address(lua_State* vm) {
|
|||
return(CONST_LUA_OK);
|
||||
}
|
||||
|
||||
/* ****************************************** */
|
||||
|
||||
static int ntop_set_lan_interface(lua_State* vm) {
|
||||
char *lan_ifname;
|
||||
ntop->getTrace()->traceEvent(TRACE_DEBUG, "%s() called", __FUNCTION__);
|
||||
|
||||
if(ntop_lua_check(vm, __FUNCTION__, 1, LUA_TSTRING) != CONST_LUA_OK) return(CONST_LUA_PARAM_ERROR);
|
||||
lan_ifname = (char*)lua_tostring(vm, 1);
|
||||
|
||||
ntop->getPrefs()->set_lan_interface(lan_ifname);
|
||||
|
||||
lua_pushnil(vm);
|
||||
return(CONST_LUA_OK);
|
||||
}
|
||||
|
||||
/* ****************************************** */
|
||||
|
||||
static int ntop_get_policy_change_marker(lua_State* vm) {
|
||||
#ifdef HAVE_NETFILTER
|
||||
NetworkInterface *ntop_interface = getCurrentInterface(vm);
|
||||
|
|
@ -7424,6 +7441,7 @@ static const luaL_Reg ntop_reg[] = {
|
|||
{ "shutdown", ntop_shutdown },
|
||||
{ "setRoutingMode", ntop_set_routing_mode },
|
||||
{ "isRoutingMode", ntop_is_routing_mode },
|
||||
{ "setLanInterface", ntop_set_lan_interface },
|
||||
#endif
|
||||
{ NULL, NULL}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ Prefs::Prefs(Ntop *_ntop) {
|
|||
user = strdup(CONST_DEFAULT_NTOP_USER);
|
||||
http_binding_address = NULL;
|
||||
https_binding_address = NULL; // CONST_ANY_ADDRESS;
|
||||
lan_interface = wan_interface = NULL;
|
||||
lan_interface = NULL;
|
||||
httpbl_key = NULL;
|
||||
cpu_affinity = NULL;
|
||||
redis_host = strdup("127.0.0.1");
|
||||
|
|
@ -157,7 +157,6 @@ Prefs::~Prefs() {
|
|||
if(http_binding_address) free(http_binding_address);
|
||||
if(https_binding_address) free(https_binding_address);
|
||||
if(lan_interface) free(lan_interface);
|
||||
if(wan_interface) free(wan_interface);
|
||||
}
|
||||
|
||||
/* ******************************************* */
|
||||
|
|
@ -553,9 +552,6 @@ void Prefs::reloadPrefsFromRedis() {
|
|||
|
||||
setTraceLevelFromRedis();
|
||||
refreshHostsAlertsPrefs();
|
||||
#ifdef HAVE_NEDGE
|
||||
refreshLanWanInterfaces();
|
||||
#endif
|
||||
|
||||
#ifdef PREFS_RELOAD_DEBUG
|
||||
ntop->getTrace()->traceEvent(TRACE_NORMAL, "Updated IPs "
|
||||
|
|
@ -1535,27 +1531,6 @@ void Prefs::refreshHostsAlertsPrefs() {
|
|||
victim_max_num_syn_per_sec = CONST_MAX_NUM_SYN_PER_SECOND;
|
||||
}
|
||||
|
||||
/* *************************************** */
|
||||
#ifdef HAVE_NEDGE
|
||||
void Prefs::refreshLanWanInterfaces() {
|
||||
char rsp[32];
|
||||
|
||||
if(lan_interface) free(lan_interface);
|
||||
if(wan_interface) free(wan_interface);
|
||||
|
||||
if(ntop->getRedis()->get((char*)CONST_RUNTIME_PREFS_LAN_INTERFACE,
|
||||
rsp, sizeof(rsp)) == 0)
|
||||
lan_interface = strdup(rsp);
|
||||
else
|
||||
lan_interface = NULL;
|
||||
|
||||
if(ntop->getRedis()->get((char*)CONST_RUNTIME_PREFS_WAN_INTERFACE,
|
||||
rsp, sizeof(rsp)) == 0)
|
||||
wan_interface = strdup(rsp);
|
||||
else
|
||||
wan_interface = NULL;
|
||||
}
|
||||
#endif
|
||||
/* *************************************** */
|
||||
|
||||
void Prefs::registerNetworkInterfaces() {
|
||||
|
|
|
|||
|
|
@ -1272,7 +1272,7 @@ void Redis::flushCache() {
|
|||
free(current);
|
||||
}
|
||||
|
||||
numCached = 0;
|
||||
stringCache = NULL, numCached = 0;
|
||||
l->unlock(__FILE__, __LINE__);
|
||||
|
||||
#ifdef CACHE_DEBUG
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue