From 79931b2ec7dffc88df4cdd6855d7b1ec95cca20f Mon Sep 17 00:00:00 2001 From: Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> Date: Sat, 10 Dec 2022 18:31:51 +0100 Subject: Fix undefined-behavior when setting empty user-agent (#1821) ``` ndpi_main.c:9111:35: runtime error: null pointer passed as argument 2, which is declared to never be null /usr/include/string.h:44:28: note: nonnull attribute specified here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ndpi_main.c:9111:35 in ``` --- src/lib/ndpi_main.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/lib') diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index 38820dc0a..7880aeae3 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -9105,6 +9105,9 @@ char *ndpi_user_agent_set(struct ndpi_flow_struct *flow, /* Already set: ignore double set */ return NULL; } + if(value_len == 0) { + return NULL; + } flow->http.user_agent = ndpi_malloc(value_len + 1); if(flow->http.user_agent != NULL) { -- cgit v1.2.3