summaryrefslogtreecommitdiffstats
path: root/meta-tpm/recipes-tpm/trousers/files/Fix-segment-fault-if-client-hostname-cannot-be-retri.patch
blob: ea6d609c7d10419fef584da1cf7f03edce717e64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
From cdc4828ea44e8cb6f8c62f9021ce37b0c1636aa4 Mon Sep 17 00:00:00 2001
From: Lans Zhang <jia.zhang@windriver.com>
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 <jia.zhang@windriver.com>
---
 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