summaryrefslogtreecommitdiff
path: root/roundcubemail
diff options
context:
space:
mode:
authoralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2009-05-22 10:45:01 +0000
committeralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2009-05-22 10:45:01 +0000
commitedd61b238397ab482a5dc53a76843e0fa3fb8ce9 (patch)
tree908e8d51383a0034d77271644e0c8fab8b7cbb15 /roundcubemail
parent681304168d26879194f6aa656d6f3315356eb345 (diff)
- handle startup response (#1484853)
git-svn-id: https://svn.roundcube.net/trunk@2521 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail')
-rw-r--r--roundcubemail/program/lib/imap.inc17
1 files changed, 14 insertions, 3 deletions
diff --git a/roundcubemail/program/lib/imap.inc b/roundcubemail/program/lib/imap.inc
index 66394dde8..932be4adf 100644
--- a/roundcubemail/program/lib/imap.inc
+++ b/roundcubemail/program/lib/imap.inc
@@ -81,6 +81,7 @@
- added \* flag support
- use PREG instead of EREG
- removed caching functions
+ - handling connection startup response
********************************************************/
@@ -229,7 +230,7 @@ function iil_PutLineC($fp, $string, $endln=true) {
return $res;
}
-function iil_ReadLine($fp, $size) {
+function iil_ReadLine($fp, $size=1024) {
$line = '';
if (!$fp) {
@@ -614,9 +615,19 @@ function iil_Connect($host, $user, $password, $options=null) {
return false;
}
- $iil_error .= "Socket connection established\r\n";
- $line = iil_ReadLine($conn->fp, 4096);
+ stream_set_timeout($conn->fp, 10);
+ $line = stream_get_line($conn->fp, 8192, "\r\n");
+ // Connected to wrong port or connection error?
+ if (!preg_match('/^\* (OK|PREAUTH)/i', $line)) {
+ if ($line)
+ $iil_error = "Wrong startup greeting ($host:$ICL_PORT): $line";
+ else
+ $iil_error = "Empty startup greeting ($host:$ICL_PORT)";
+ $iil_errornum = -2;
+ return false;
+ }
+
// RFC3501 [7.1] optional CAPABILITY response
if (preg_match('/\[CAPABILITY ([^]]+)\]/i', $line, $matches)) {
$conn->capability = explode(' ', strtoupper($matches[1]));