[dovecot-cvs] dovecot/src/master login-process.c, 1.77, 1.78 login-process.h, 1.8, 1.9

cras at dovecot.org cras at dovecot.org
Mon Sep 25 15:07:14 EEST 2006


Update of /var/lib/cvs/dovecot/src/master
In directory talvi:/tmp/cvs-serv3427

Modified Files:
	login-process.c login-process.h 
Log Message:
SIGHUP caused memory corruption



Index: login-process.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/master/login-process.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- login-process.c	25 Sep 2006 10:30:59 -0000	1.77
+++ login-process.c	25 Sep 2006 12:07:12 -0000	1.78
@@ -63,6 +63,7 @@
 	struct login_group *group;
 
 	group = i_new(struct login_group, 1);
+	group->refcount = 1;
 	group->set = set;
 	group->process_type = set->protocol == MAIL_PROTOCOL_IMAP ?
 		PROCESS_TYPE_IMAP : PROCESS_TYPE_POP3;
@@ -71,8 +72,13 @@
 	login_groups = group;
 }
 
-static void login_group_destroy(struct login_group *group)
+static void login_group_unref(struct login_group *group)
 {
+	i_assert(group->refcount > 0);
+
+	if (--group->refcount > 0)
+		return;
+
 	i_free(group);
 }
 
@@ -300,6 +306,12 @@
 		login_process_destroy(p);
 		return;
 	}
+	{
+		static int i = 0;
+		if (i++ > 1) {
+			ret = -1; errno = EINVAL;
+		}
+	}
 
 	if (ret != sizeof(req)) {
 		if (ret == 0) {
@@ -383,6 +395,7 @@
 	p->state = LOGIN_STATE_LISTENING;
 
 	if (p->group != NULL) {
+		p->group->refcount++;
 		p->group->processes++;
 		p->group->listening_processes++;
 	}
@@ -425,6 +438,9 @@
 	if (--p->refcount > 0)
 		return;
 
+	if (p->group != NULL)
+		login_group_unref(p->group);
+
 	o_stream_unref(&p->output);
 	i_free(p);
 }
@@ -637,7 +653,7 @@
 		struct login_group *group = login_groups;
 
 		login_groups = group->next;
-		login_group_destroy(group);
+		login_group_unref(group);
 	}
 }
 

Index: login-process.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/master/login-process.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- login-process.h	6 Aug 2006 20:05:36 -0000	1.8
+++ login-process.h	25 Sep 2006 12:07:12 -0000	1.9
@@ -3,6 +3,7 @@
 
 struct login_group {
 	struct login_group *next;
+	int refcount;
 
 	enum process_type process_type;
 	struct settings *set;



More information about the dovecot-cvs mailing list