Fix invalid categories labels array length and add check
This commit is contained in:
+116
-107
@@ -314,6 +314,116 @@ int strncasecmp(s1, s2, n)
|
|||||||
|
|
||||||
/* ****************************************** */
|
/* ****************************************** */
|
||||||
|
|
||||||
|
/* Keep it in order and in sync with ndpi_protocol_category_t in ndpi_typedefs.h */
|
||||||
|
static const char* categories[] = {
|
||||||
|
"Unspecified",
|
||||||
|
"Media",
|
||||||
|
"VPN",
|
||||||
|
"Email",
|
||||||
|
"DataTransfer",
|
||||||
|
"Web",
|
||||||
|
"SocialNetwork",
|
||||||
|
"Download-FileTransfer-FileSharing",
|
||||||
|
"Game",
|
||||||
|
"Chat",
|
||||||
|
"VoIP",
|
||||||
|
"Database",
|
||||||
|
"RemoteAccess",
|
||||||
|
"Cloud",
|
||||||
|
"Network",
|
||||||
|
"Collaborative",
|
||||||
|
"RPC",
|
||||||
|
"Streaming",
|
||||||
|
"System",
|
||||||
|
"SoftwareUpdate",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"Music",
|
||||||
|
"Video",
|
||||||
|
"Shopping",
|
||||||
|
"Productivity",
|
||||||
|
"FileSharing",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"Mining", /* 99 */
|
||||||
|
"Malware",
|
||||||
|
"Advertisement",
|
||||||
|
"Banned_Site",
|
||||||
|
"Site_Unavailable"
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ****************************************** */
|
||||||
|
|
||||||
/* Forward */
|
/* Forward */
|
||||||
static void addDefaultPort(struct ndpi_detection_module_struct *ndpi_mod,
|
static void addDefaultPort(struct ndpi_detection_module_struct *ndpi_mod,
|
||||||
ndpi_port_range *range,
|
ndpi_port_range *range,
|
||||||
@@ -2239,6 +2349,12 @@ struct ndpi_detection_module_struct *ndpi_init_detection_module(void) {
|
|||||||
ndpi_str->bigrams_automa.ac_automa = ac_automata_init(ac_match_handler);
|
ndpi_str->bigrams_automa.ac_automa = ac_automata_init(ac_match_handler);
|
||||||
ndpi_str->impossible_bigrams_automa.ac_automa = ac_automata_init(ac_match_handler);
|
ndpi_str->impossible_bigrams_automa.ac_automa = ac_automata_init(ac_match_handler);
|
||||||
|
|
||||||
|
if((sizeof(categories)/sizeof(char*)) != NDPI_PROTOCOL_NUM_CATEGORIES) {
|
||||||
|
NDPI_LOG_ERR(ndpi_str, "[NDPI] invalid categories length: expected %u, got %u\n",
|
||||||
|
NDPI_PROTOCOL_NUM_CATEGORIES, (sizeof(categories)/sizeof(char*)));
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_HYPERSCAN
|
#ifdef HAVE_HYPERSCAN
|
||||||
ndpi_str->custom_categories.num_to_load = 0, ndpi_str->custom_categories.to_load = NULL;
|
ndpi_str->custom_categories.num_to_load = 0, ndpi_str->custom_categories.to_load = NULL;
|
||||||
ndpi_str->custom_categories.hostnames = NULL;
|
ndpi_str->custom_categories.hostnames = NULL;
|
||||||
@@ -5671,113 +5787,6 @@ void ndpi_category_set_name(struct ndpi_detection_module_struct *ndpi_mod,
|
|||||||
|
|
||||||
/* ****************************************************** */
|
/* ****************************************************** */
|
||||||
|
|
||||||
/* Keep it in order and in sync with ndpi_protocol_category_t in ndpi_typedefs.h */
|
|
||||||
static const char* categories[] = {
|
|
||||||
"Unspecified",
|
|
||||||
"Media",
|
|
||||||
"VPN",
|
|
||||||
"Email",
|
|
||||||
"DataTransfer",
|
|
||||||
"Web",
|
|
||||||
"SocialNetwork",
|
|
||||||
"Download-FileTransfer-FileSharing",
|
|
||||||
"Game",
|
|
||||||
"Chat",
|
|
||||||
"VoIP",
|
|
||||||
"Database",
|
|
||||||
"RemoteAccess",
|
|
||||||
"Cloud",
|
|
||||||
"Network",
|
|
||||||
"Collaborative",
|
|
||||||
"RPC",
|
|
||||||
"Streaming",
|
|
||||||
"System",
|
|
||||||
"SoftwareUpdate",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"Music",
|
|
||||||
"Video",
|
|
||||||
"Shopping",
|
|
||||||
"Productivity",
|
|
||||||
"FileSharing",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
|
|
||||||
"Mining", /* 99 */
|
|
||||||
"Malware",
|
|
||||||
"Advertisement",
|
|
||||||
"Banned_Site",
|
|
||||||
"Site_Unavailable"
|
|
||||||
};
|
|
||||||
|
|
||||||
const char* ndpi_category_get_name(struct ndpi_detection_module_struct *ndpi_mod,
|
const char* ndpi_category_get_name(struct ndpi_detection_module_struct *ndpi_mod,
|
||||||
ndpi_protocol_category_t category) {
|
ndpi_protocol_category_t category) {
|
||||||
if((!ndpi_mod) || (category >= NDPI_PROTOCOL_NUM_CATEGORIES))
|
if((!ndpi_mod) || (category >= NDPI_PROTOCOL_NUM_CATEGORIES))
|
||||||
|
|||||||
Reference in New Issue
Block a user