projects
/
oweals
/
tinc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
Check the return value of fscanf() when reading a PID file.
[oweals/tinc.git]
/
lib
/
pidfile.c
diff --git
a/lib/pidfile.c
b/lib/pidfile.c
index 426cbf392c10d903add23a1ae130fd9e4b96bfb7..dd6788a6539fea41ed1ce2790ab3446d795f5055 100644
(file)
--- a/
lib/pidfile.c
+++ b/
lib/pidfile.c
@@
-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;
}