cid#318900 Out-of-bounds write

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I18f30bbe7271a93a44ce798e358277add9876454
pull/7072/head
Caolán McNamara 2023-08-10 09:56:56 +01:00 committed by Miklos Vajna
parent 307818ba1c
commit 6682a2a527
1 changed files with 1 additions and 1 deletions

View File

@ -637,7 +637,7 @@ static unsigned getParent(int proc_id)
char buffer[4096];
int len;
if ((len = read(fd, buffer, sizeof (buffer))) < 0)
if ((len = read(fd, buffer, sizeof (buffer) - 1)) < 0)
error(EXIT_FAILURE, errno, "Failed to read /proc/%d/stat", proc_id);
close (fd);
buffer[len] = '\0';