[Pkg-owncloud-commits] [php-sabre-vobject] 90/128: Don't go into an infinite loop.

David Prévot taffit at moszumanska.debian.org
Tue May 20 23:11:05 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository php-sabre-vobject.

commit 033ee6bf5afe608da18ffbaf09c4e5059f809af0
Author: Evert Pot <evert at rooftopsolutions.nl>
Date:   Wed Apr 2 16:54:53 2014 -0400

    Don't go into an infinite loop.
    
    Fix for #86.
---
 ChangeLog.md                         | 3 ++-
 lib/Sabre/VObject/Parser/MimeDir.php | 9 +++++++--
 tests/Sabre/VObject/ReaderTest.php   | 8 ++++++++
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/ChangeLog.md b/ChangeLog.md
index eb0b690..2f51324 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -23,7 +23,8 @@ ChangeLog
 * Added: Support for DateTime objects in the VCard DATE-AND-OR-TIME property.
 * Added: UUIDUtil, for easily creating unique identifiers.
 * Fixed: Issue #83. Creating new VALUE=DATE objects using php's DateTime.
-
+* Fixed: Issue #86. Don't go into an infinite loop when php errors are
+  disabled and an invalid file is read.
 
 3.1.4 (2014-03-30)
 ------------------
diff --git a/lib/Sabre/VObject/Parser/MimeDir.php b/lib/Sabre/VObject/Parser/MimeDir.php
index 672b237..473f30f 100644
--- a/lib/Sabre/VObject/Parser/MimeDir.php
+++ b/lib/Sabre/VObject/Parser/MimeDir.php
@@ -228,10 +228,15 @@ class MimeDir extends Parser {
             $this->lineBuffer = null;
         } else {
             do {
-                $rawLine = fgets($this->input);
-                if ($rawLine === false && feof($this->input)) {
+                $eof = feof($this->input);
+                if ($eof) {
                     throw new EofException('End of document reached prematurely');
                 }
+
+                $rawLine = fgets($this->input);
+                if ($rawLine === false) {
+                    throw new ParseException('Error reading from input stream');
+                }
                 $rawLine = rtrim($rawLine, "\r\n");
             } while ($rawLine === ''); // Skipping empty lines
             $this->lineIndex++;
diff --git a/tests/Sabre/VObject/ReaderTest.php b/tests/Sabre/VObject/ReaderTest.php
index 5f8d6e8..577024d 100644
--- a/tests/Sabre/VObject/ReaderTest.php
+++ b/tests/Sabre/VObject/ReaderTest.php
@@ -427,5 +427,13 @@ ICS;
 
     }
 
+    /**
+     * @expectedException PHPUnit_Framework_Error_Warning
+     */
+    public function testReadBrokenInput() {
+
+        Reader::read(false);
+
+    }
 
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabre-vobject.git



More information about the Pkg-owncloud-commits mailing list