pgrep: Replace buf+1 with buf in read_pidfile().
Unless we missed something, this makes it unnecessarily difficult to read/audit.
This commit is contained in:
parent
c1dbd41d2b
commit
5d2b44eaf6
6
pgrep.c
6
pgrep.c
@ -251,11 +251,11 @@ static struct el *read_pidfile(void)
|
|||||||
if(opt_lock && !has_flock(fd) && !has_fcntl(fd))
|
if(opt_lock && !has_flock(fd) && !has_fcntl(fd))
|
||||||
goto out;
|
goto out;
|
||||||
memset(buf,'\0',sizeof buf);
|
memset(buf,'\0',sizeof buf);
|
||||||
n = read(fd,buf+1,sizeof buf-2);
|
n = read(fd,buf,sizeof buf-1);
|
||||||
if (n<1)
|
if (n<1)
|
||||||
goto out;
|
goto out;
|
||||||
pid = strtoul(buf+1,&endp,10);
|
pid = strtoul(buf,&endp,10);
|
||||||
if(endp<=buf+1 || pid<1 || pid>0x7fffffff)
|
if(endp<=buf || pid<1 || pid>0x7fffffff)
|
||||||
goto out;
|
goto out;
|
||||||
if(*endp && !isspace(*endp))
|
if(*endp && !isspace(*endp))
|
||||||
goto out;
|
goto out;
|
||||||
|
Loading…
Reference in New Issue
Block a user