Check the return value of fscanf() when reading a PID file.
This commit is contained in:
parent
5e0efd53e7
commit
3e55dc77f4
1 changed files with 3 additions and 2 deletions
|
@ -37,11 +37,12 @@
|
|||
pid_t read_pid (char *pidfile)
|
||||
{
|
||||
FILE *f;
|
||||
long pid = 0;
|
||||
long pid;
|
||||
|
||||
if (!(f=fopen(pidfile,"r")))
|
||||
return 0;
|
||||
fscanf(f,"%ld", &pid);
|
||||
if(fscanf(f,"%ld", &pid) != 1)
|
||||
pid = 0;
|
||||
fclose(f);
|
||||
return pid;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue