From ca7f7a4006e1005e3f014ed5187a4369dfcba714 Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Mon, 30 Oct 2017 11:49:21 -0400 Subject: [PATCH] swtpm: fix segfault introduced in aa3999 Changeset aa3999 introduced a segfault when calling ctrlchannel_set_client_fd() with a NULL pointer. Like all the other functions, we return with -1 in this case. Since the segfault occurred on process shutdown no problems were noticeable through bad test results or so. Signed-off-by: Stefan Berger --- src/swtpm/ctrlchannel.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/swtpm/ctrlchannel.c b/src/swtpm/ctrlchannel.c index 760d264..d52d5c2 100644 --- a/src/swtpm/ctrlchannel.c +++ b/src/swtpm/ctrlchannel.c @@ -114,8 +114,12 @@ int ctrlchannel_get_client_fd(struct ctrlchannel *cc) int ctrlchannel_set_client_fd(struct ctrlchannel *cc, int fd) { - int clientfd = cc->clientfd; + int clientfd; + if (!cc) + return -1; + + clientfd = cc->clientfd; cc->clientfd = fd; return clientfd;