Skip to content

Commit

Permalink
virtfs-proxy-helper: Fix possible socket leak.
Browse files Browse the repository at this point in the history
Signed-off-by: Gonglei <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
  • Loading branch information
gongleiarei authored and Michael Tokarev committed Feb 10, 2015
1 parent 46ede58 commit 88ea8ed
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions fsdev/virtfs-proxy-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,24 +749,29 @@ static int proxy_socket(const char *path, uid_t uid, gid_t gid)
if (bind(sock, (struct sockaddr *)&proxy,
sizeof(struct sockaddr_un)) < 0) {
do_perror("bind");
return -1;
goto error;
}
if (chown(proxy.sun_path, uid, gid) < 0) {
do_perror("chown");
return -1;
goto error;
}
if (listen(sock, 1) < 0) {
do_perror("listen");
return -1;
goto error;
}

size = sizeof(qemu);
client = accept(sock, (struct sockaddr *)&qemu, &size);
if (client < 0) {
do_perror("accept");
return -1;
goto error;
}
close(sock);
return client;

error:
close(sock);
return -1;
}

static void usage(char *prog)
Expand Down

0 comments on commit 88ea8ed

Please sign in to comment.