From 920b0ada70e9c3137505c2645c67f4f63dc79c50 Mon Sep 17 00:00:00 2001 From: Qualys Security Advisory Date: Thu, 1 Jan 1970 00:00:00 +0000 Subject: [PATCH] proc/sysinfo.c: Ensure null-termination in getstat(). There was a "buff[BUFFSIZE-1] = 0;" but there may be garbage between what is read() (less than BUFFSIZE-1 bytes) and this null byte. Reuse the construct from the preceding getrunners(). --- proc/sysinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proc/sysinfo.c b/proc/sysinfo.c index 42646942..4b2090be 100644 --- a/proc/sysinfo.c +++ b/proc/sysinfo.c @@ -524,7 +524,7 @@ void getstat(jiff *restrict cuse, jiff *restrict cice, jiff *restrict csys, jiff int need_vmstat_file = 0; int need_proc_scan = 0; const char* b; - buff[BUFFSIZE-1] = 0; /* ensure null termination in buffer */ + memset(buff, '\0', BUFFSIZE); /* ensure null termination in buffer */ if(fd){ lseek(fd, 0L, SEEK_SET); -- 2.40.0