summaryrefslogtreecommitdiff
path: root/p11-kit
diff options
context:
space:
mode:
authorDaiki Ueno <dueno@redhat.com>2018-08-01 15:24:20 +0200
committerDaiki Ueno <dueno@redhat.com>2018-08-01 15:24:20 +0200
commit22cb49b9105657cafb98624be37f05b169f73dd6 (patch)
treeadaca286fce737eb1a4112b8da5fe532b052b1d3 /p11-kit
parent19aaf573580e52265f57f9b7af7a03bfdfaf71e0 (diff)
server: Avoid FD leak in error cases
Spotted by coverity.
Diffstat (limited to 'p11-kit')
-rw-r--r--p11-kit/server.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/p11-kit/server.c b/p11-kit/server.c
index 87d6ad4..a737c2a 100644
--- a/p11-kit/server.c
+++ b/p11-kit/server.c
@@ -277,12 +277,14 @@ create_socket (const char *address,
umask (066);
rc = bind (sd, (struct sockaddr *)&sa, SUN_LEN (&sa));
if (rc == -1) {
+ close (sd);
p11_message_err (errno, "could not bind socket %s", socket_file);
return -1;
}
rc = listen (sd, 1024);
if (rc == -1) {
+ close (sd);
p11_message_err (errno, "could not listen to socket %s", socket_file);
return 1;
}
@@ -290,6 +292,7 @@ create_socket (const char *address,
if (uid != -1 && gid != -1) {
rc = chown (socket_file, uid, gid);
if (rc == -1) {
+ close (sd);
p11_message_err (errno, "could not chown socket %s", socket_file);
return -1;
}