dovecot: If dotlock file contains pid <= 0, assume it's invalid.

dovecot at dovecot.org dovecot at dovecot.org
Sat Dec 29 18:59:37 EET 2007


details:   http://hg.dovecot.org/dovecot/rev/04e048fcd6d7
changeset: 7065:04e048fcd6d7
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Dec 29 18:59:34 2007 +0200
description:
If dotlock file contains pid <= 0, assume it's invalid.

diffstat:

1 file changed, 5 insertions(+), 1 deletion(-)
src/lib/file-dotlock.c |    6 +++++-

diffs (23 lines):

diff -r 046d06f52aa6 -r 04e048fcd6d7 src/lib/file-dotlock.c
--- a/src/lib/file-dotlock.c	Sat Dec 29 18:45:11 2007 +0200
+++ b/src/lib/file-dotlock.c	Sat Dec 29 18:59:34 2007 +0200
@@ -88,6 +88,7 @@ static pid_t read_local_pid(const char *
 	char buf[512], *host;
 	int fd;
 	ssize_t ret;
+	pid_t pid;
 
 	fd = open(lock_path, O_RDONLY);
 	if (fd == -1)
@@ -116,7 +117,10 @@ static pid_t read_local_pid(const char *
 
 	if (!is_numeric(buf, '\0'))
 		return -1;
-	return (pid_t)strtoul(buf, NULL, 0);
+	pid = (pid_t)strtoul(buf, NULL, 0);
+	if (pid <= 0)
+		return -1;
+	return pid;
 }
 
 static bool


More information about the dovecot-cvs mailing list