<?xml version="1.0"?>
<?xml-stylesheet
href="http://www.w3.org/2000/08/w3c-synd/style.css" type="text/css"
?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel rdf:about="http://pear.php.net/bugs/search.php">
    <title>PEAR Bug Search Results</title>
    <link>http://pear.php.net/bugs/search.php?cmd=display&amp;package_name%5B0%5D=OLE</link>
    <description>Search Results</description>
    <dc:language>en-us</dc:language>
    <dc:creator>pear-webmaster@lists.php.net</dc:creator>
    <dc:publisher>pear-webmaster@lists.php.net</dc:publisher>
    <admin:generatorAgent rdf:resource="http://pear.php.net/bugs"/>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
    <items>
     <rdf:Seq>
      <rdf:li rdf:resource="http://pear.php.net/bug/28646" />
      <rdf:li rdf:resource="http://pear.php.net/bug/21243" />
      <rdf:li rdf:resource="http://pear.php.net/bug/21175" />

     </rdf:Seq>
    </items>
  </channel>

  <image rdf:about="http://pear.php.net/gifs/pearsmall.gif">
    <title>PEAR Bugs</title>
    <url>http://pear.php.net/gifs/pearsmall.gif</url>
    <link>http://pear.php.net/bugs</link>
  </image>

    <item rdf:about="http://pear.php.net/bug/28646">
      <title>OLE: Feature/Change Request 28646 [Open] allow using a strem for writing output</title>
      <link>http://pear.php.net/bugs/28646</link>
      <content:encoded><![CDATA[<pre>OLE Feature/Change Request
Reported by gggeek
2024-07-26T12:37:20+00:00
PHP: 8.0.0 (Specify exact version in description) OS: linux Package Version: 1.0.0RC3

Description:
------------
In `Root::save()`, we could allow the caller to pass in an already open stream. This would allow to save f.e. to a memory stream, without the need for temp files</pre>]]></content:encoded>
      <description><![CDATA[<pre>OLE Feature/Change Request
Reported by gggeek
2024-07-26T12:37:20+00:00
PHP: 8.0.0 (Specify exact version in description) OS: linux Package Version: 1.0.0RC3

Description:
------------
In `Root::save()`, we could allow the caller to pass in an already open stream. This would allow to save f.e. to a memory stream, without the need for temp files</pre>]]></description>
      <dc:date>2024-07-26T12:37:20+00:00</dc:date>
      <dc:creator>giunta &amp;#x64;&amp;#111;&amp;#x74; gaetano &amp;#x61;&amp;#116; gmail &amp;#x64;&amp;#111;&amp;#x74; com</dc:creator>
      <dc:subject>OLE Feature/Change Request</dc:subject>
    </item>
    <item rdf:about="http://pear.php.net/bug/21243">
      <title>OLE: Bug 21243 [Open] small blocks (&quot;mini stream&quot;) handling is broken</title>
      <link>http://pear.php.net/bugs/21243</link>
      <content:encoded><![CDATA[<pre>OLE Bug
Reported by tacituseu
2017-09-26T15:12:16+00:00
PHP: Irrelevant OS: Any Package Version: 1.0.0RC3

Description:
------------
In OLE\ChainedBlockStream.php::stream_open() there is this:

if (isset($this-&gt;params['size']) &amp;&amp; $this-&gt;params['size'] &lt; $this-&gt;ole-
&gt;bigBlockThreshold &amp;&amp; $blockId != $this-&gt;ole-&gt;root-&gt;startBlock) {
		// Block id refers to small blocks
		$rootPos = $this-&gt;ole-&gt;_getBlockOffset($this-&gt;ole-&gt;root-
&gt;startBlock);
		while ($blockId != -2) {
				$pos = $rootPos + $blockId * $this-&gt;ole-
&gt;bigBlockSize;
				$blockId = $this-&gt;ole-&gt;sbat[$blockId];
				fseek($this-&gt;ole-&gt;_file_handle, $pos);
				$this-&gt;data .= fread($this-&gt;ole-&gt;_file_handle, 
$this-&gt;ole-&gt;bigBlockSize);

		}
}

Problems:
1. small blocks ([MS-CFB].pdf: &quot;mini stream&quot;) isn't a continuous space, 
but a stream itself:
$rootPos = $this-&gt;ole-&gt;_getBlockOffset($this-&gt;ole-&gt;root-&gt;startBlock);
will work only for simple documents that don't contain entries with size 
larger than $this-&gt;ole-&gt;bigBlockThreshold

what you want is in OLE.php::_readPpsWks():

$this-&gt;_list[] = $pps; 
if ($type == OLE_PPS_TYPE_ROOT) {
	$this-&gt;_small_handle = $this-&gt;getStream($pps-&gt;startBlock);
}
and then use it in point 2

Reference: [MS-CFB].pdf 2.6.1 Root Directory Entry

2. wrong block size used for fread
fread($this-&gt;ole-&gt;_file_handle, $this-&gt;ole-&gt;bigBlockSize);
should be:
fread($this-&gt;ole-&gt;_small_handle, $this-&gt;ole-&gt;smallBlockSize);

Test script:
---------------
$obj = new OLE();
$obj-&gt;read('ole.xls');
foreach ($obj-&gt;_list as $idx =&gt; $pps) if ($obj-&gt;isFile($idx)) {
  $dlen = $olz-&gt;getDataLength($idx);
  $data = $olz-&gt;getData($idx, 0, $dlen);
  var_dump($data);
}

Expected result:
----------------
data corresponding to given entry

Actual result:
--------------
data corresponding to given entry for some entries (up to first big block entry 
which breaks assumption of continuity for small stream)</pre>]]></content:encoded>
      <description><![CDATA[<pre>OLE Bug
Reported by tacituseu
2017-09-26T15:12:16+00:00
PHP: Irrelevant OS: Any Package Version: 1.0.0RC3

Description:
------------
In OLE\ChainedBlockStream.php::stream_open() there is this:

if (isset($this-&gt;params['size']) &amp;&amp; $this-&gt;params['size'] &lt; $this-&gt;ole-
&gt;bigBlockThreshold &amp;&amp; $blockId != $this-&gt;ole-&gt;root-&gt;startBlock) {
		// Block id refers to small blocks
		$rootPos = $this-&gt;ole-&gt;_getBlockOffset($this-&gt;ole-&gt;root-
&gt;startBlock);
		while ($blockId != -2) {
				$pos = $rootPos + $blockId * $this-&gt;ole-
&gt;bigBlockSize;
				$blockId = $this-&gt;ole-&gt;sbat[$blockId];
				fseek($this-&gt;ole-&gt;_file_handle, $pos);
				$this-&gt;data .= fread($this-&gt;ole-&gt;_file_handle, 
$this-&gt;ole-&gt;bigBlockSize);

		}
}

Problems:
1. small blocks ([MS-CFB].pdf: &quot;mini stream&quot;) isn't a continuous space, 
but a stream itself:
$rootPos = $this-&gt;ole-&gt;_getBlockOffset($this-&gt;ole-&gt;root-&gt;startBlock);
will work only for simple documents that don't contain entries with size 
larger than $this-&gt;ole-&gt;bigBlockThreshold

what you want is in OLE.php::_readPpsWks():

$this-&gt;_list[] = $pps; 
if ($type == OLE_PPS_TYPE_ROOT) {
	$this-&gt;_small_handle = $this-&gt;getStream($pps-&gt;startBlock);
}
and then use it in point 2

Reference: [MS-CFB].pdf 2.6.1 Root Directory Entry

2. wrong block size used for fread
fread($this-&gt;ole-&gt;_file_handle, $this-&gt;ole-&gt;bigBlockSize);
should be:
fread($this-&gt;ole-&gt;_small_handle, $this-&gt;ole-&gt;smallBlockSize);

Test script:
---------------
$obj = new OLE();
$obj-&gt;read('ole.xls');
foreach ($obj-&gt;_list as $idx =&gt; $pps) if ($obj-&gt;isFile($idx)) {
  $dlen = $olz-&gt;getDataLength($idx);
  $data = $olz-&gt;getData($idx, 0, $dlen);
  var_dump($data);
}

Expected result:
----------------
data corresponding to given entry

Actual result:
--------------
data corresponding to given entry for some entries (up to first big block entry 
which breaks assumption of continuity for small stream)</pre>]]></description>
      <dc:date>2018-10-23T09:16:24+00:00</dc:date>
      <dc:creator>tacituseu &amp;#x61;&amp;#116; gmail &amp;#x64;&amp;#111;&amp;#x74; com</dc:creator>
      <dc:subject>OLE Bug</dc:subject>
    </item>
    <item rdf:about="http://pear.php.net/bug/21175">
      <title>OLE: Bug 21175 [Open] Corrupt OLE header generated for files approximately 7mb in size.</title>
      <link>http://pear.php.net/bugs/21175</link>
      <content:encoded><![CDATA[<pre>OLE Bug
Reported by obarshay
2017-02-02T08:01:22+00:00
PHP: Irrelevant OS:  Package Version: 1.0.0RC2

Description:
------------
When the total number of block pointers is 109 (the number that can fit 
in the header), an extension block pointer is added to the header. To fix, 
make the following change to Root.php:259

        if ($iBdCnt &lt; $i1stBdL) {

to:
        if ($iBdCnt &lt;= $i1stBdL) {</pre>]]></content:encoded>
      <description><![CDATA[<pre>OLE Bug
Reported by obarshay
2017-02-02T08:01:22+00:00
PHP: Irrelevant OS:  Package Version: 1.0.0RC2

Description:
------------
When the total number of block pointers is 109 (the number that can fit 
in the header), an extension block pointer is added to the header. To fix, 
make the following change to Root.php:259

        if ($iBdCnt &lt; $i1stBdL) {

to:
        if ($iBdCnt &lt;= $i1stBdL) {</pre>]]></description>
      <dc:date>2018-10-31T06:11:02+00:00</dc:date>
      <dc:creator>oleg &amp;#x61;&amp;#116; barshaysoftware &amp;#x64;&amp;#111;&amp;#x74; com</dc:creator>
      <dc:subject>OLE Bug</dc:subject>
    </item>
</rdf:RDF>
