[evolution-patches] camel fix for 61761




if we got an i/o error pe->current could be left pointing to a command which is freed by a caller.

this aborts all current and outstanding requests as soon as we encounter an i/o error in the main loop.

--
Michael Zucchi <notzed ximian com>
"born to die, live to work, it's all downhill from here"
Novell's Evolution and Free Software Developer
Index: camel/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.2223
diff -u -3 -r1.2223 ChangeLog
--- camel/ChangeLog	21 Jul 2004 15:55:00 -0000	1.2223
+++ camel/ChangeLog	22 Jul 2004 06:43:58 -0000
@@ -1,3 +1,11 @@
+2004-07-22  Not Zed  <NotZed Ximian com>
+
+	** See bug #61761.
+
+	* providers/pop3/camel-pop3-engine.c (camel_pop3_engine_iterate):
+	if we get an io error, move every current/active and queued
+	command to the done queue and mark as failed.
+
 2004-07-19  Jeffrey Stedfast  <fejj novell com>
 
 	* providers/imap/camel-imap-store.c (get_subscribed_folders): Free
Index: camel/providers/pop3/camel-pop3-engine.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/providers/pop3/camel-pop3-engine.c,v
retrieving revision 1.8
diff -u -3 -r1.8 camel-pop3-engine.c
--- camel/providers/pop3/camel-pop3-engine.c	24 Jun 2004 21:49:40 -0000	1.8
+++ camel/providers/pop3/camel-pop3-engine.c	22 Jul 2004 06:43:58 -0000
@@ -293,7 +293,7 @@
 	/* LOCK */
 
 	if (camel_pop3_stream_line(pe->stream, &pe->line, &pe->linelen) == -1)
-		return -1;
+		goto ioerror;
 
 	p = pe->line;
 	switch (p[0]) {
@@ -339,7 +339,7 @@
 			break;
 
 		if (camel_stream_write((CamelStream *)pe->stream, pw->data, strlen(pw->data)) == -1)
-			return -1;
+			goto ioerror;
 
 		e_dlist_remove((EDListNode *)pw);
 
@@ -361,6 +361,25 @@
 		return 0;
 
 	return pe->current==NULL?0:1;
+ioerror:
+	/* we assume all outstanding commands are gunna fail now */
+	while ( (pw = (CamelPOP3Command*)e_dlist_remhead(&pe->active)) ) {
+		pw->state = CAMEL_POP3_COMMAND_ERR;
+		e_dlist_addtail(&pe->done, (EDListNode *)pw);
+	}
+
+	while ( (pw = (CamelPOP3Command*)e_dlist_remhead(&pe->queue)) ) {
+		pw->state = CAMEL_POP3_COMMAND_ERR;
+		e_dlist_addtail(&pe->done, (EDListNode *)pw);
+	}
+
+	if (pe->current) {
+		pe->current->state = CAMEL_POP3_COMMAND_ERR;
+		e_dlist_addtail(&pe->done, (EDListNode *)pe->current);
+		pe->current = NULL;
+	}
+
+	return -1;
 }
 
 CamelPOP3Command *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]