Limit field width when scanning PID file.
Cppcheck warns that scanf() might otherwise crash when presented with a huge, bogus PID file.
This commit is contained in:
parent
3ce5e292da
commit
d7636352ce
1 changed files with 1 additions and 1 deletions
|
@ -41,7 +41,7 @@ pid_t read_pid (char *pidfile)
|
|||
|
||||
if (!(f=fopen(pidfile,"r")))
|
||||
return 0;
|
||||
if(fscanf(f,"%ld", &pid) != 1)
|
||||
if(fscanf(f,"%20ld", &pid) != 1)
|
||||
pid = 0;
|
||||
fclose(f);
|
||||
return pid;
|
||||
|
|
Loading…
Reference in a new issue