From 5eba0be26859c16fb008fcd3fc0647ff305dae43 Mon Sep 17 00:00:00 2001 From: stekkel Date: Wed, 18 Jun 2003 22:11:09 +0000 Subject: [PATCH] Ahhh, this doesn't work when the buffer is smaller then the size of the attachment. Can somebody fix this? git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@5085 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/imap_general.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/functions/imap_general.php b/functions/imap_general.php index d7109bc6..dcb8d612 100755 --- a/functions/imap_general.php +++ b/functions/imap_general.php @@ -104,19 +104,23 @@ function sqimap_fread($imap_stream,$iSize,$filter=false, if (!$filter || !$outputstream) { $iBufferSize = $iSize; } else { - $iBufferSize = 32768; + // FIXME This doesn't work with base64 decode, Why ? + // The idea is to use a buffersize of 32k i.e. + $iBufferSize = $iSize; } $iRet = $iSize - $iBufferSize; + $iRetrieved = 0; $i = 0; $results = ''; - while (($i * $iBufferSize) < $iRet) { + while (($iRetrieved < ($iSize - $iBufferSize))) { $sRead = fread($imap_stream,$iBufferSize); - if (!$sRead) { + if ($sRead === false) { $results = false; break; } - ++$i; + $iRetrieved += $iBufferSize; if ($filter) { + $filter($sRead); } if ($outputstream) { @@ -132,7 +136,7 @@ function sqimap_fread($imap_stream,$iSize,$filter=false, $results .= $sRead; } if ($results !== false) { - $sRead = fread($imap_stream,($iSize - ($i * $iBufferSize))); + $sRead = fread($imap_stream,($iSize - ($iRetrieved))); if ($filter) { $filter($sRead); } -- 2.25.1