proc/sysinfo.c: Fix off-by-one in get_pid_digits().

At "pidbuf[rc] = '\0';" if "rc = read()" returns "sizeof pidbuf"
(unlikely to ever happen, but still).
This commit is contained in:
Qualys Security Advisory 1970-01-01 00:00:00 +00:00 committed by Craig Small
parent 8136a7a664
commit a33be33885

View File

@ -1140,7 +1140,7 @@ unsigned get_pid_digits(void){
ret = 5;
fd = open("/proc/sys/kernel/pid_max", O_RDONLY);
if(fd==-1) goto out;
rc = read(fd, pidbuf, sizeof pidbuf);
rc = read(fd, pidbuf, sizeof pidbuf - 1);
close(fd);
if(rc<3) goto out;
pidbuf[rc] = '\0';