mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-04 11:05:10 +00:00
coverity: #1425801
Resource leak Signed-off-by: Donghwa Jeong <dh48.jeong@samsung.com>
This commit is contained in:
parent
7177e6b155
commit
928388738b
@ -216,18 +216,11 @@ int lxc_monitor_open(const char *lxcpath)
|
||||
if (lxc_monitor_sock_name(lxcpath, &addr) < 0)
|
||||
return -1;
|
||||
|
||||
fd = socket(PF_UNIX, SOCK_STREAM, 0);
|
||||
if (fd < 0) {
|
||||
ERROR("Failed to create socket: %s.", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
len = strlen(&addr.sun_path[1]);
|
||||
DEBUG("opening monitor socket %s with len %zu", &addr.sun_path[1], len);
|
||||
if (len >= sizeof(addr.sun_path) - 1) {
|
||||
errno = ENAMETOOLONG;
|
||||
ERROR("name of monitor socket too long (%zu bytes): %s", len, strerror(errno));
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -342,16 +342,9 @@ static int lxc_monitor_open(const char *lxcpath)
|
||||
if (lxc_monitor_sock_name(lxcpath, &addr) < 0)
|
||||
return -1;
|
||||
|
||||
fd = socket(PF_UNIX, SOCK_STREAM, 0);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "Failed to create socket: %s\n", strerror(errno));
|
||||
return -errno;
|
||||
}
|
||||
|
||||
len = strlen(&addr.sun_path[1]);
|
||||
if (len >= sizeof(addr.sun_path) - 1) {
|
||||
errno = ENAMETOOLONG;
|
||||
close(fd);
|
||||
fprintf(stderr, "name of monitor socket too long (%zu bytes): %s\n", len, strerror(errno));
|
||||
return -errno;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user