summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortill <till@php.net>2008-03-22 13:15:00 +0000
committertill <till@php.net>2008-03-22 13:15:00 +0000
commitb5c2469d4921f70e0a47ae7261c70cd263b39b72 (patch)
treeea50debbc3a9fadbfc0a2715ef6d4d432e2916f3
parent03fcc16896fdd31973ad21c67b33da6fe0b6b579 (diff)
* committed a suggestion from #1483956
* cleaned up two functions
-rw-r--r--program/lib/imap.inc42
1 files changed, 23 insertions, 19 deletions
diff --git a/program/lib/imap.inc b/program/lib/imap.inc
index 3d20d9e37..96353dd2f 100644
--- a/program/lib/imap.inc
+++ b/program/lib/imap.inc
@@ -161,18 +161,19 @@ function iil_xor($string, $string2) {
}
function iil_ReadLine($fp, $size) {
- $line = '';
- if ($fp) {
- do {
- // FIXME: hardcode size?
- $buffer = fgets($fp, 2048);
- if ($buffer === false) {
- break;
- }
- $line .= $buffer;
- } while ($buffer[strlen($buffer)-1]!="\n");
- }
- return $line;
+ $line = '';
+ if (!$fp) {
+ return $line;
+ }
+ do {
+ // FIXME: hardcode size?
+ $buffer = fgets($fp, 2048);
+ if ($buffer === false) {
+ break;
+ }
+ $line .= $buffer;
+ } while ($buffer[strlen($buffer)-1] != "\n");
+ return $line;
}
function iil_MultLine($fp, $line) {
@@ -192,13 +193,16 @@ function iil_MultLine($fp, $line) {
}
function iil_ReadBytes($fp, $bytes) {
- $data = '';
- $len = 0;
- do {
- $data.=fread($fp, $bytes-$len);
- $len = strlen($data);
- } while ($len<$bytes);
- return $data;
+ $data = '';
+ $len = 0;
+ do {
+ $data .= fread($fp, $bytes-$len);
+ if ($len == strlen($data)) {
+ break; //nothing was read -> exit to avoid apache lockups
+ }
+ $len = strlen($data);
+ } while ($len < $bytes);
+ return $data;
}
function iil_ReadReply($fp) {