From 937dcb38eacec02cf7fc8aa6f587caf98b545a4b Mon Sep 17 00:00:00 2001 From: emanuele-f Date: Thu, 26 Sep 2019 12:15:49 +0200 Subject: Fix bad protocols returned in ndpi_detection_giveup when detection is already complete --- src/lib/ndpi_main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index 418ceaf2e..56031e299 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -4044,8 +4044,14 @@ ndpi_protocol ndpi_detection_giveup(struct ndpi_detection_module_struct *ndpi_st if(flow == NULL) return(ret); - else - ret.category = flow->category; + + /* Init defaults */ + ret.master_protocol = flow->detected_protocol_stack[1], ret.app_protocol = flow->detected_protocol_stack[0]; + ret.category = flow->category; + + /* Ensure that we don't change our mind if detection is already complete */ + if((ret.master_protocol != NDPI_PROTOCOL_UNKNOWN) && (ret.app_protocol != NDPI_PROTOCOL_UNKNOWN)) + return(ret); /* TODO: add the remaining stage_XXXX protocols */ if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) { -- cgit v1.2.3