From a33be338856a436e41f2cbdcfd4b25f09dc18358 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: Fix off-by-one in get_pid_digits(). At "pidbuf[rc] = '\0';" if "rc = read()" returns "sizeof pidbuf" (unlikely to ever happen, but still). --- proc/sysinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proc/sysinfo.c b/proc/sysinfo.c index f0f705ff..42646942 100644 --- a/proc/sysinfo.c +++ b/proc/sysinfo.c @@ -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';