Skip to content

Commit

Permalink
Merge pull request #10 from hfig/master
Browse files Browse the repository at this point in the history
Fix for PEAR bug #21243
  • Loading branch information
sanmai authored Nov 13, 2018
2 parents 528bd98 + 091019e commit dd51ded
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
10 changes: 10 additions & 0 deletions OLE.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ class OLE extends PEAR
*/
var $_file_handle;

/**
* Reference to the sbat stream
* @var resource
*/
var $_small_handle;

/**
* Array of PPS's found on the OLE container
* @var array
Expand Down Expand Up @@ -361,6 +367,10 @@ function _readPpsWks($blockId)
$pps->No = count($this->_list);
$this->_list[] = $pps;

if ($type == OLE_PPS_TYPE_ROOT) {
$this->_small_handle = $this->getStream($pps->_StartBlock);
}

// check if the PPS tree (starting from root) is complete
if (isset($this->root) &&
$this->_ppsTreeComplete($this->root->No)) {
Expand Down
11 changes: 6 additions & 5 deletions OLE/ChainedBlockStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,13 @@ function stream_open($path, $mode, $options, &$openedPath)
$blockId != $this->ole->root->_StartBlock) {

// Block id refers to small blocks
$rootPos = $this->ole->_getBlockOffset($this->ole->root->_StartBlock);
$rootPos = 0;
while ($blockId != -2) {
$pos = $rootPos + $blockId * $this->ole->bigBlockSize;
$blockId = $this->ole->sbat[$blockId];
fseek($this->ole->_file_handle, $pos);
$this->data .= fread($this->ole->_file_handle, $this->ole->bigBlockSize);
$pos = $rootPos + $blockId * $this->ole->smallBlockSize;

$blockId = $this->ole->sbat[$blockId];
fseek($this->ole->_small_handle, $pos);
$this->data .= fread($this->ole->_small_handle, $this->ole->smallBlockSize);
}
} else {
// Block id refers to big blocks
Expand Down

0 comments on commit dd51ded

Please sign in to comment.