source4/smbd/pidfile: don't panic if pid file is corrupt.
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 28 Jun 2012 01:34:25 +0000 (11:04 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 28 Jun 2012 03:19:24 +0000 (05:19 +0200)
In particular, on a virtual machine after a forced reboot, it
contained "Ille" instead of a valid PID.  Given it was the right
length, I'm assuming it was filesystem corruption.

process_exists_by_pid() then panics, when given a pid < 1.

Reported-by: lostogre on #samba-technical
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-User(master): Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date(master): Thu Jun 28 05:19:24 CEST 2012 on sn-devel-104

source4/smbd/pidfile.c

index b7d1c27cd0f0a99fcff0bf0925f42903c970e15e..32d3964302ecfe0ccf10e35ee876264b9e727001 100644 (file)
@@ -57,6 +57,9 @@ pid_t pidfile_pid(const char *piddir, const char *name)
        }
 
        ret = (pid_t)atoi(pidstr);
+       if (ret <= 0) {
+               goto noproc;
+       }
        
        if (!process_exists_by_pid(ret)) {
                goto noproc;