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:
Guus Sliepen 2011-01-02 16:52:36 +01:00
parent 3ce5e292da
commit d7636352ce

View file

@ -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;