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 <stefanb@linux.vnet.ibm.com>
This commit is contained in:
Stefan Berger 2017-10-30 11:49:21 -04:00 committed by Stefan Berger
parent 061f9dce5e
commit ca7f7a4006

View File

@ -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;