Skip to content
Snippets Groups Projects
Commit d4fed2cd authored by Peter Rotich's avatar Peter Rotich
Browse files

Merge pull request #825 from greezybacon/issue/tnef-bad-rewind


tnef: Fix major issue iterating over attar streams

Reviewed-By: default avatarPeter Rotich <peter@osticket.com>
parents 54157bc3 34d8d0b4
No related branches found
No related tags found
No related merge requests found
...@@ -278,15 +278,14 @@ class TnefAttributeStreamReader extends TnefStreamReader { ...@@ -278,15 +278,14 @@ class TnefAttributeStreamReader extends TnefStreamReader {
$this->push($stream); $this->push($stream);
/* Number of attributes. */ /* Number of attributes. */
$this->count = $this->_geti(32); $this->count = $this->_geti(32);
$this->next();
} }
function valid() { function valid() {
return (bool) $this->current; return $this->count && $this->current;
} }
function rewind() { function rewind() {
$this->pos = 0; $this->pos = 4;
} }
protected function readPhpValue($type) { protected function readPhpValue($type) {
...@@ -350,10 +349,11 @@ class TnefAttributeStreamReader extends TnefStreamReader { ...@@ -350,10 +349,11 @@ class TnefAttributeStreamReader extends TnefStreamReader {
} }
function next() { function next() {
$this->count--; if ($this->count <= 0) {
if ($this->length - $this->pos < 12)
return $this->current = false; return $this->current = false;
}
$this->count--;
$have_mval = false; $have_mval = false;
$named_id = $value = null; $named_id = $value = null;
...@@ -391,7 +391,7 @@ class TnefAttributeStreamReader extends TnefStreamReader { ...@@ -391,7 +391,7 @@ class TnefAttributeStreamReader extends TnefStreamReader {
$value = $this->readPhpValue($data_type); $value = $this->readPhpValue($data_type);
} else { } else {
$value = array(); $value = array();
$k = $this->_geti(32); $k = $this->_geti(32);
for ($i=0; $i < $k; $i++) for ($i=0; $i < $k; $i++)
$value[] = $this->readPhpValue($data_type); $value[] = $this->readPhpValue($data_type);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment