Fix off-by-one fgets() usage.
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 29 May 2009 02:53:22 +0000 (20:53 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 29 May 2009 02:53:22 +0000 (20:53 -0600)
Pays to read the manual.  fgets() reads 8192 - 1 bytes, so the index of
the last byte is 8190, not 8191.

framework/Imap_Client/lib/Horde/Imap/Client/Socket.php

index 058d905..d1155ca 100644 (file)
@@ -3217,7 +3217,7 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base
                  * will result in read errors. */
                 if ($tmp = fgets($this->_stream, 8192)) {
                     $data .= $tmp;
-                    if (!isset($tmp[8191]) || ($tmp[8191] == "\n")) {
+                    if (!isset($tmp[8190]) || ($tmp[8190] == "\n")) {
                         break;
                     }
                 }