summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2009-05-10 08:37:11 +0000
committeralecpl <alec@alec.pl>2009-05-10 08:37:11 +0000
commit4769ead5e8fa2cbee61ac6675d499cb16d7ffb7c (patch)
treeb195f29a13c416cffb4f149f1b5fc4c6efa6d1ac
parent26d857447f5a9d2e8a9c44fd5707a18523926e1d (diff)
- prevent infinite loop on imap error in iil_C_HandlePartBody()
-rw-r--r--program/lib/imap.inc15
1 files changed, 7 insertions, 8 deletions
diff --git a/program/lib/imap.inc b/program/lib/imap.inc
index f7a46d648..1295d5fa6 100644
--- a/program/lib/imap.inc
+++ b/program/lib/imap.inc
@@ -2323,7 +2323,7 @@ function iil_C_HandlePartBody(&$conn, $mailbox, $id, $part='', $mode=1, $file=NU
if (iil_C_Select($conn, $mailbox)) {
$reply_key = '* ' . $id;
-
+
// format request
$key = 'ftch' . ($c++) . ' ';
$request = $key . "FETCH $id (BODY.PEEK[$part])";
@@ -2336,7 +2336,7 @@ function iil_C_HandlePartBody(&$conn, $mailbox, $id, $part='', $mode=1, $file=NU
do {
$line = chop(iil_ReadLine($fp, 1000));
$a = explode(' ', $line);
- } while ($a[2] != 'FETCH');
+ } while (!($end = iil_StartsWith($line, $key, true)) && $a[2] != 'FETCH');
$len = strlen($line);
// handle empty "* X FETCH ()" response
@@ -2407,9 +2407,10 @@ function iil_C_HandlePartBody(&$conn, $mailbox, $id, $part='', $mode=1, $file=NU
}
}
// read in anything up until last line
- do {
- $line = iil_ReadLine($fp, 1024);
- } while (!iil_StartsWith($line, $key, true));
+ if (!$end)
+ do {
+ $line = iil_ReadLine($fp, 1024);
+ } while (!iil_StartsWith($line, $key, true));
if ($mode == 3 && $file) {
return true;
@@ -2425,12 +2426,10 @@ function iil_C_HandlePartBody(&$conn, $mailbox, $id, $part='', $mode=1, $file=NU
}
return false;
- } else {
- echo 'Select failed.';
}
if ($mode==1) {
- if ($file) {
+ if ($file && $result) {
fwrite($file, $result);
return true;
}