From: Guus Sliepen Date: Tue, 8 Sep 2009 16:18:16 +0000 (+0200) Subject: Check the return value of fscanf() when reading a PID file. X-Git-Tag: release-1.0.10~45 X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=3e55dc77f4ba19fd9e79f3d5ce9d28bb6b05019e;p=tinc Check the return value of fscanf() when reading a PID file. --- diff --git a/lib/pidfile.c b/lib/pidfile.c index 426cbf39..dd6788a6 100644 --- 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; }