mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-27 09:35:31 +00:00
coverity: #1425760
Use of untrusted scalar value Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
parent
d3ccc04e79
commit
7635665611
@ -1136,17 +1136,27 @@ static int ls_serialize(int wpipefd, struct ls *n)
|
|||||||
|
|
||||||
static int ls_recv_str(int fd, char **buf)
|
static int ls_recv_str(int fd, char **buf)
|
||||||
{
|
{
|
||||||
|
ssize_t ret;
|
||||||
size_t slen = 0;
|
size_t slen = 0;
|
||||||
if (lxc_read_nointr(fd, &slen, sizeof(slen)) != sizeof(slen))
|
|
||||||
|
ret = lxc_read_nointr(fd, &slen, sizeof(slen));
|
||||||
|
if (ret != sizeof(slen))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (slen > 0) {
|
if (slen > 0) {
|
||||||
*buf = malloc(sizeof(char) * (slen + 1));
|
*buf = malloc(sizeof(char) * (slen + 1));
|
||||||
if (!*buf)
|
if (!*buf)
|
||||||
return -1;
|
return -1;
|
||||||
if (lxc_read_nointr(fd, *buf, slen) != (ssize_t)slen)
|
|
||||||
|
ret = lxc_read_nointr(fd, *buf, slen);
|
||||||
|
if (ret != (ssize_t)slen) {
|
||||||
|
free(*buf);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
(*buf)[slen] = '\0';
|
(*buf)[slen] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user