From cdc4828ea44e8cb6f8c62f9021ce37b0c1636aa4 Mon Sep 17 00:00:00 2001 From: Lans Zhang Date: Thu, 12 May 2016 23:55:44 +0800 Subject: [PATCH] Fix segment fault if client hostname cannot be retrieve Upstream-Status: Pending When tcsd cannot resolve the hostname of client, the constant C string INVALID_ADDR_STR is used to identify the client. The host name eventually be freed by calling free(), which will violate the memory protection for sure. To fix this issue, always create a freeable INVALID_ADDR_STR. Signed-off-by: Lans Zhang --- src/tcsd/svrside.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tcsd/svrside.c b/src/tcsd/svrside.c index 1ae1636..692211c 100644 --- a/src/tcsd/svrside.c +++ b/src/tcsd/svrside.c @@ -557,7 +557,7 @@ main(int argc, char **argv) hostname = fetch_hostname(&client_addr, client_len); if (hostname == NULL) - hostname=INVALID_ADDR_STR; + hostname=strdup(INVALID_ADDR_STR); tcsd_thread_create(newsd, hostname); hostname = NULL; -- 1.9.1