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 ```
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user