From 9e0bb6bcdedd113b7a1496defb5daef98be3dde0 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Tue, 03 Jul 2007 13:37:20 -0400
Subject: [PATCH] Applied socket error patch by Thomas Mangin

---
 CHANGELOG            |    1 +
 program/lib/imap.inc |   11 ++++++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 95c3b57..e0a4c3f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,7 @@
 - Added Macedonian (Slavic FYROM) localization
 - Fix status message bug #1484464 with regard to #1484353
 - Fix address adding bug reported by David Koblas
+- Applied socket error patch by Thomas Mangin
 
 
 2007/06/28 (tomekp)
diff --git a/program/lib/imap.inc b/program/lib/imap.inc
index 6bc47a1..05b1c00 100644
--- a/program/lib/imap.inc
+++ b/program/lib/imap.inc
@@ -48,6 +48,7 @@
 		- Also acceppt LIST responses in iil_C_ListSubscribed()
 		- Sanity check of $message_set in iil_C_FetchHeaders(), iil_C_FetchHeaderIndex(), iil_C_FetchThreadHeaders()
 		- Implemented UID FETCH in iil_C_FetchHeaders()
+		- Abort do-loop on socket errors (fgets returns false)
 		- Removed some debuggers (echo ...)
 
 ********************************************************/
@@ -130,6 +131,8 @@
 	if ($fp){
 		do{
 			$buffer = fgets($fp, 2048);
+			if ($buffer === false)
+				break;
 			$line.=$buffer;
 		}while($buffer[strlen($buffer)-1]!="\n");
 	}
@@ -229,9 +232,11 @@
     $password = strtr($password, array('"'=>'\\"', '\\' => '\\\\'));  
     fputs($conn->fp, "a001 LOGIN $user \"$password\"\r\n");
 
-	do{
-	    $line = iil_ReadReply($conn->fp);
-	}while(!iil_StartsWith($line, "a001 "));
+  do{
+    $line = iil_ReadReply($conn->fp);
+    if ($line === false)
+      break;
+  }while(!iil_StartsWith($line, "a001 "));
     $a=explode(" ", $line);
     if (strcmp($a[1],"OK")==0){
         $result=$conn->fp;

--
Gitblit v1.9.1