From: Guus Sliepen Date: Sun, 2 Jan 2011 15:52:36 +0000 (+0100) Subject: Limit field width when scanning PID file. X-Git-Tag: release-1.0.14~20 X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=commitdiff_plain;h=d7636352ce359e807b392a6e5ac0a6aeff4a63d2 Limit field width when scanning PID file. Cppcheck warns that scanf() might otherwise crash when presented with a huge, bogus PID file. --- diff --git a/lib/pidfile.c b/lib/pidfile.c index 47f6359f..425b3043 100644 --- a/lib/pidfile.c +++ b/lib/pidfile.c @@ -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;