]> granicus.if.org Git - procps-ng/commitdiff
pgrep: Replace buf+1 with buf in read_pidfile().
authorQualys Security Advisory <qsa@qualys.com>
Thu, 1 Jan 1970 00:00:00 +0000 (00:00 +0000)
committerCraig Small <csmall@enc.com.au>
Fri, 18 May 2018 21:32:21 +0000 (07:32 +1000)
Unless we missed something, this makes it unnecessarily difficult to
read/audit.

pgrep.c

diff --git a/pgrep.c b/pgrep.c
index 676326612eeb793193606b2dacd9e56d8d9c235b..dead923c851fb9889467a036125f81fbe95d4b86 100644 (file)
--- a/pgrep.c
+++ b/pgrep.c
@@ -251,11 +251,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>0x7fffffff)
+       pid = strtoul(buf,&endp,10);
+       if(endp<=buf || pid<1 || pid>0x7fffffff)
                goto out;
        if(*endp && !isspace(*endp))
                goto out;