From 2a0052f25e9781928b62b28a7a032e690903cf48 Mon Sep 17 00:00:00 2001 From: Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> Date: Sun, 10 Sep 2023 15:07:52 +0200 Subject: fuzz: add fuzzers to test reader_util code (#2080) --- example/reader_util.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'example/reader_util.c') diff --git a/example/reader_util.c b/example/reader_util.c index 071acb774..fff77f139 100644 --- a/example/reader_util.c +++ b/example/reader_util.c @@ -436,7 +436,7 @@ int parse_proto_name_list(char *str, NDPI_PROTOCOL_BITMASK *bitmask, int inverte } proto = ndpi_get_proto_id(module, n); if(proto == NDPI_PROTOCOL_UNKNOWN && strcmp(n,"unknown") && strcmp(n,"0")) { - fprintf(stderr,"Invalid protocol %s\n",n); + LOG(NDPI_LOG_ERROR, "Invalid protocol %s\n", n); ndpi_exit_detection_module(module); return 1; } @@ -475,7 +475,7 @@ struct ndpi_workflow* ndpi_workflow_init(const struct ndpi_workflow_prefs * pref workflow = ndpi_calloc(1, sizeof(struct ndpi_workflow)); if(workflow == NULL) { LOG(NDPI_LOG_ERROR, "global structure initialization failed\n"); - ndpi_free(module); + ndpi_exit_detection_module(module); return NULL; } @@ -489,8 +489,11 @@ struct ndpi_workflow* ndpi_workflow_init(const struct ndpi_workflow_prefs * pref if(_debug_protocols != NULL && ! _debug_protocols_ok) { NDPI_BITMASK_RESET(debug_bitmask); - if(parse_proto_name_list(_debug_protocols, &debug_bitmask, 0)) - exit(-1); + if(parse_proto_name_list(_debug_protocols, &debug_bitmask, 0)) { + ndpi_exit_detection_module(module); + ndpi_free(workflow); + return NULL; + } _debug_protocols_ok = 1; } if(_debug_protocols_ok) -- cgit v1.2.3