aboutsummaryrefslogtreecommitdiff
path: root/src/lib/protocols/http.c
diff options
context:
space:
mode:
authorToni <matzeton@googlemail.com>2022-04-25 13:00:50 +0200
committerGitHub <noreply@github.com>2022-04-25 13:00:50 +0200
commitbc2ad3407a1cf7f6d2913f113df31dfbf735c6f6 (patch)
treea06e65f5d38238a894dea0415b2b6584cd027e4f /src/lib/protocols/http.c
parent075bce5f3de463975464472158dca980a45f48a3 (diff)
Added generic user agent setter. (#1530)
* ndpiReader: Print user agent if one was set and not just for certain protocols. Signed-off-by: lns <matzeton@googlemail.com>
Diffstat (limited to 'src/lib/protocols/http.c')
-rw-r--r--src/lib/protocols/http.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/lib/protocols/http.c b/src/lib/protocols/http.c
index 8b65ece50..8ecadb303 100644
--- a/src/lib/protocols/http.c
+++ b/src/lib/protocols/http.c
@@ -535,14 +535,11 @@ int http_process_user_agent(struct ndpi_detection_module_struct *ndpi_struct,
}
}
- if(flow->http.user_agent == NULL) {
- flow->http.user_agent = ndpi_malloc(ua_ptr_len + 1);
- if(flow->http.user_agent) {
- memcpy(flow->http.user_agent, (char*)ua_ptr, ua_ptr_len);
- flow->http.user_agent[ua_ptr_len] = '\0';
-
- ndpi_check_user_agent(ndpi_struct, flow, flow->http.user_agent);
- }
+ if (ndpi_user_agent_set(flow, ua_ptr, ua_ptr_len) != NULL)
+ {
+ ndpi_check_user_agent(ndpi_struct, flow, flow->http.user_agent);
+ } else {
+ NDPI_LOG_DBG2(ndpi_struct, "Could not set HTTP user agent\n");
}
NDPI_LOG_DBG2(ndpi_struct, "User Agent Type line found %.*s\n",