From c68f84c3f8239cdf7de2f58c6244b3ffdf6c6ca6 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Mon, 10 Sep 2012 11:36:28 -0500 Subject: [PATCH] [zendframework/zf2#2280] Fix bad assignment condition - By changing to do a boolean comparison, this broke -- because trim() always returns a string, the boolean comparison always passed, leading to an infinite loop. Fixed the code to work as expected, while still removing the CS notice. --- src/Adapter/Digest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Adapter/Digest.php b/src/Adapter/Digest.php index 960a6fa..7ae7e73 100644 --- a/src/Adapter/Digest.php +++ b/src/Adapter/Digest.php @@ -189,7 +189,11 @@ public function authenticate() 'messages' => array() ); - while (($line = trim(fgets($fileHandle))) !== false) { + while (($line = fgets($fileHandle)) !== false) { + $line = trim($line); + if (empty($line)) { + break; + } if (substr($line, 0, $idLength) === $id) { if ($this->_secureStringCompare(substr($line, -32), md5("$this->username:$this->realm:$this->password"))) { $result['code'] = AuthenticationResult::SUCCESS;