diff --git a/changelog.md b/changelog.md index 5256844b..e8377558 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,7 @@ # ChangeLog +* Handle bare codes (an RFC contravention) in SMTP server responses + ## Version 5.2.23 (March 15th 2017) * Improve trapping of TLS errors during connection so that they don't cause warnings, and are reported better in debug output * Amend test suite so it uses PHPUnit version 4.8, compatible with older versions of PHP, instead of teh version supplied by Travis-CI diff --git a/class.smtp.php b/class.smtp.php index 01cee820..010a7aa6 100644 --- a/class.smtp.php +++ b/class.smtp.php @@ -1089,8 +1089,10 @@ class SMTP $this->edebug("SMTP -> get_lines(): \$data is \"$data\"", self::DEBUG_LOWLEVEL); $this->edebug("SMTP -> get_lines(): \$str is \"$str\"", self::DEBUG_LOWLEVEL); $data .= $str; - // If 4th character is a space, we are done reading, break the loop, micro-optimisation over strlen - if ((isset($str[3]) and $str[3] == ' ')) { + // If response is only 3 chars (not valid, but RFC5321 S4.2 says it must be handled), + // or 4th character is a space, we are done reading, break the loop, + // string array access is a micro-optimisation over strlen + if (!isset($str[3]) or (isset($str[3]) and $str[3] == ' ')) { break; } // Timed-out? Log and break