aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Nardi <12729895+IvanNardi@users.noreply.github.com>2022-12-10 18:31:51 +0100
committerGitHub <noreply@github.com>2022-12-10 18:31:51 +0100
commit79931b2ec7dffc88df4cdd6855d7b1ec95cca20f (patch)
tree0c1cae111eae60fb7740dc74c0a3e0d07f51bca7
parent9dc433f709c12e65c8e7c99e70029bb7af8e04ee (diff)
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 ```
-rw-r--r--src/lib/ndpi_main.c3
1 files changed, 3 insertions, 0 deletions
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) {