From: Qualys Security Advisory Date: Thu, 1 Jan 1970 00:00:00 +0000 (+0000) Subject: 0004-pgrep: Replace buf+1 with buf in read_pidfile(). X-Git-Tag: v4.0.0~523 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8e3e77910da5f6ac7caf2f8151793feadd28de25;p=procps-ng 0004-pgrep: Replace buf+1 with buf in read_pidfile(). Unless we missed something, this makes it unnecessarily difficult to read/audit. --- diff --git a/pgrep.c b/pgrep.c index 36936900..ffe0f32a 100644 --- a/pgrep.c +++ b/pgrep.c @@ -266,11 +266,11 @@ static struct el *read_pidfile(void) if(opt_lock && !has_flock(fd) && !has_fcntl(fd)) goto out; memset(buf,'\0',sizeof buf); - n = read(fd,buf+1,sizeof buf-2); + n = read(fd,buf,sizeof buf-1); if (n<1) goto out; - pid = strtoul(buf+1,&endp,10); - if(endp<=buf+1 || pid<1 ) + pid = strtoul(buf,&endp,10); + if(endp<=buf || pid<1 ) goto out; if(*endp && !isspace(*endp)) goto out;