summaryrefslogtreecommitdiff
path: root/program/lib/Roundcube/rcube_smtp.php
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-05-08 20:19:58 +0200
committerAleksander Machniak <alec@alec.pl>2013-05-08 20:19:58 +0200
commit9b8d22ebe14a2a6d3f5c8bebee0a3126a72521cc (patch)
treeafee4436eee3e7bf1a4c7e258d2b51d8edbffb00 /program/lib/Roundcube/rcube_smtp.php
parenta522971cf853b2f0ccd1b569491a06218ebbaee9 (diff)
Limit debug log entry (line) size to 4096 characters to prevent
memory_limit/preformance issues when debug is enabled (imap, smtp, db)
Diffstat (limited to 'program/lib/Roundcube/rcube_smtp.php')
-rw-r--r--program/lib/Roundcube/rcube_smtp.php7
1 files changed, 7 insertions, 0 deletions
diff --git a/program/lib/Roundcube/rcube_smtp.php b/program/lib/Roundcube/rcube_smtp.php
index 0f3ac0407..6ba766672 100644
--- a/program/lib/Roundcube/rcube_smtp.php
+++ b/program/lib/Roundcube/rcube_smtp.php
@@ -33,6 +33,8 @@ class rcube_smtp
// define headers delimiter
const SMTP_MIME_CRLF = "\r\n";
+ const DEBUG_LINE_LENGTH = 4096;
+
/**
* SMTP Connection and authentication
@@ -327,6 +329,11 @@ class rcube_smtp
*/
public function debug_handler(&$smtp, $message)
{
+ if (($len = strlen($message)) > self::DEBUG_LINE_LENGTH) {
+ $message = substr_replace($message, "\n-----[debug cut]----\n",
+ self::DEBUG_LINE_LENGTH/2 - 11, $len - self::DEBUG_LINE_LENGTH - 22);
+ }
+
rcube::write_log('smtp', preg_replace('/\r\n$/', '', $message));
}