From 087e299e542a53050a247a39f29206878b08aacc Mon Sep 17 00:00:00 2001 From: lns Date: Mon, 25 Apr 2022 11:39:33 +0200 Subject: Added generic user agent setter. * ndpiReader: Print user agent if one was set and not just for certain protocols. Signed-off-by: lns --- src/lib/protocols/xiaomi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/lib/protocols/xiaomi.c') diff --git a/src/lib/protocols/xiaomi.c b/src/lib/protocols/xiaomi.c index 831478e9e..f18c6202b 100644 --- a/src/lib/protocols/xiaomi.c +++ b/src/lib/protocols/xiaomi.c @@ -52,10 +52,9 @@ static void xiaomi_dissect_metadata(struct ndpi_detection_module_struct *ndpi_st switch(op) { case 0x12: - flow->http.user_agent = ndpi_malloc(len + 1); - if(flow->http.user_agent != NULL) { - memcpy(flow->http.user_agent, &payload[offset], len); - flow->http.user_agent[len] = '\0'; + if (ndpi_user_agent_set(flow, &payload[offset], len) == NULL) + { + NDPI_LOG_DBG2(ndpi_struct, "Could not set Xiaomi user agent\n"); } break; -- cgit v1.2.3