[dovecot-cvs] dovecot/src/master login-process.c, 1.73.2.4, 1.73.2.5 login-process.h, 1.7.2.1, 1.7.2.2

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-serv20226

Modified Files:
      Tag: branch_1_0
	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.73.2.4
retrieving revision 1.73.2.5
diff -u -d -r1.73.2.4 -r1.73.2.5
--- login-process.c	25 Sep 2006 10:30:58 -0000	1.73.2.4
+++ login-process.c	25 Sep 2006 12:07:11 -0000	1.73.2.5
@@ -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.7.2.1
retrieving revision 1.7.2.2
diff -u -d -r1.7.2.1 -r1.7.2.2
--- login-process.h	6 Aug 2006 20:05:25 -0000	1.7.2.1
+++ login-process.h	25 Sep 2006 12:07:11 -0000	1.7.2.2
@@ -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