virtfs-proxy-helper: Fix possible socket leak.
Signed-off-by: Gonglei <arei.gonglei@huawei.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
parent
46ede58bb4
commit
88ea8ed74c
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user