1
0
mirror of https://passt.top/passt synced 2024-07-06 17:56:15 +00:00

passt: Ignoring number of bytes read, CWE-252

Harmless, assuming sane kernel behaviour. Reported by Coverity.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
Stefano Brivio 2022-04-05 05:21:18 +02:00
parent dbd0a7035c
commit 975ee8eb2b

View File

@ -195,6 +195,7 @@ static void seccomp(const struct ctx *c)
*/ */
static void check_root(void) static void check_root(void)
{ {
const char root_uid_map[] = " 0 0 4294967295";
struct passwd *pw; struct passwd *pw;
char buf[BUFSIZ]; char buf[BUFSIZ];
int fd; int fd;
@ -205,8 +206,8 @@ static void check_root(void)
if ((fd = open("/proc/self/uid_map", O_RDONLY | O_CLOEXEC)) < 0) if ((fd = open("/proc/self/uid_map", O_RDONLY | O_CLOEXEC)) < 0)
return; return;
if (read(fd, buf, BUFSIZ) > 0 && if (read(fd, buf, BUFSIZ) != sizeof(root_uid_map) ||
strcmp(buf, " 0 0 4294967295")) { strncmp(buf, root_uid_map, sizeof(root_uid_map) - 1)) {
close(fd); close(fd);
return; return;
} }