projects
/
tinc
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
5e0efd5
)
Check the return value of fscanf() when reading a PID file.
author
Guus Sliepen
<guus@tinc-vpn.org>
Tue, 8 Sep 2009 16:18:16 +0000
(18:18 +0200)
committer
Guus Sliepen
<guus@tinc-vpn.org>
Tue, 8 Sep 2009 16:18:16 +0000
(18:18 +0200)
lib/pidfile.c
patch
|
blob
|
history
diff --git
a/lib/pidfile.c
b/lib/pidfile.c
index
426cbf3
..
dd6788a
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;
}