Merge pull request #791 from ntop/ndpi_hs
Fix crash due to recent code changes when using hyperscan and mining_…
This commit is contained in:
@@ -88,6 +88,6 @@ void ndpi_timer_sub(const struct timeval *a, const struct timeval *b, struct tim
|
|||||||
void ndpi_timer_clear(struct timeval *a);
|
void ndpi_timer_clear(struct timeval *a);
|
||||||
unsigned int ndpi_timeval_to_milliseconds(struct timeval ts);
|
unsigned int ndpi_timeval_to_milliseconds(struct timeval ts);
|
||||||
unsigned int ndpi_timeval_to_microseconds(struct timeval ts);
|
unsigned int ndpi_timeval_to_microseconds(struct timeval ts);
|
||||||
void ndpi_log_timestamp(char *log_ts, u_int log_ts_len);
|
void ndpi_log_timestamp(char *log_ts, uint32_t log_ts_len);
|
||||||
|
|
||||||
#endif /* NDPI_CLASSIFY_H */
|
#endif /* NDPI_CLASSIFY_H */
|
||||||
|
|||||||
@@ -679,7 +679,7 @@ ndpi_timeval_to_microseconds(struct timeval ts)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ndpi_log_timestamp(char *log_ts, u_int log_ts_len)
|
ndpi_log_timestamp(char *log_ts, uint32_t log_ts_len)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
time_t nowtime;
|
time_t nowtime;
|
||||||
|
|||||||
+10
-3
@@ -4258,7 +4258,6 @@ void ndpi_load_ip_category(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
*/
|
*/
|
||||||
int ndpi_load_hostname_category(struct ndpi_detection_module_struct *ndpi_str,
|
int ndpi_load_hostname_category(struct ndpi_detection_module_struct *ndpi_str,
|
||||||
char *name, ndpi_protocol_category_t category) {
|
char *name, ndpi_protocol_category_t category) {
|
||||||
AC_PATTERN_t ac_pattern;
|
|
||||||
|
|
||||||
if(name == NULL)
|
if(name == NULL)
|
||||||
return(-1);
|
return(-1);
|
||||||
@@ -4267,8 +4266,6 @@ int ndpi_load_hostname_category(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
printf("===> %s() Loading %s as %u\n", __FUNCTION__, name, category);
|
printf("===> %s() Loading %s as %u\n", __FUNCTION__, name, category);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
memset(&ac_pattern, 0, sizeof(ac_pattern));
|
|
||||||
|
|
||||||
#ifdef HAVE_HYPERSCAN
|
#ifdef HAVE_HYPERSCAN
|
||||||
{
|
{
|
||||||
struct hs_list *h = (struct hs_list*)ndpi_malloc(sizeof(struct hs_list));
|
struct hs_list *h = (struct hs_list*)ndpi_malloc(sizeof(struct hs_list));
|
||||||
@@ -4287,6 +4284,10 @@ int ndpi_load_hostname_category(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
AC_PATTERN_t ac_pattern;
|
||||||
|
|
||||||
|
memset(&ac_pattern, 0, sizeof(ac_pattern));
|
||||||
|
|
||||||
if(ndpi_str->custom_categories.hostnames_shadow.ac_automa == NULL)
|
if(ndpi_str->custom_categories.hostnames_shadow.ac_automa == NULL)
|
||||||
return(-1);
|
return(-1);
|
||||||
|
|
||||||
@@ -4336,6 +4337,11 @@ int ndpi_enable_loaded_categories(struct ndpi_detection_module_struct *ndpi_str)
|
|||||||
head = head->next;
|
head = head->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(i != ndpi_str->custom_categories.num_to_load){
|
||||||
|
ndpi_free(expressions);
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
free_hyperscan_memory(ndpi_str->custom_categories.hostnames);
|
free_hyperscan_memory(ndpi_str->custom_categories.hostnames);
|
||||||
ndpi_str->custom_categories.hostnames = (struct hs*)ndpi_malloc(sizeof(struct hs));
|
ndpi_str->custom_categories.hostnames = (struct hs*)ndpi_malloc(sizeof(struct hs));
|
||||||
|
|
||||||
@@ -4361,6 +4367,7 @@ int ndpi_enable_loaded_categories(struct ndpi_detection_module_struct *ndpi_str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ndpi_str->custom_categories.to_load = NULL;
|
ndpi_str->custom_categories.to_load = NULL;
|
||||||
|
ndpi_str->custom_categories.num_to_load = 0;
|
||||||
|
|
||||||
if(rc < 0) {
|
if(rc < 0) {
|
||||||
ndpi_free(ndpi_str->custom_categories.hostnames);
|
ndpi_free(ndpi_str->custom_categories.hostnames);
|
||||||
|
|||||||
Reference in New Issue
Block a user