From 70aa29167ec47407abd2f6bf89ea72330fadc10b Mon Sep 17 00:00:00 2001 From: Zxilly Date: Thu, 11 May 2023 11:40:44 +0800 Subject: [PATCH] fix: custom ua filled with space but not \0 --- src/handler.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/handler.c b/src/handler.c index e091c4f..c16c923 100644 --- a/src/handler.c +++ b/src/handler.c @@ -31,7 +31,8 @@ void init_handler() { replacement_user_agent_string = malloc(MAX_USER_AGENT_LENGTH); #ifdef UA2F_CUSTOM_UA - strncpy(replacement_user_agent_string, UA2F_CUSTOM_UA, MAX_USER_AGENT_LENGTH); + memset(replacement_user_agent_string, ' ', MAX_USER_AGENT_LENGTH); + strncpy(replacement_user_agent_string, UA2F_CUSTOM_UA, strlen(UA2F_CUSTOM_UA)); syslog(LOG_INFO, "Custom user agent string: %s", replacement_user_agent_string); #else memset(replacement_user_agent_string, 'F', MAX_USER_AGENT_LENGTH);