generated from jric11/baseProject
Codex's updates...
This commit is contained in:
@@ -61,6 +61,9 @@ class OLERead
|
||||
/** @var mixed[][] */
|
||||
private array $props = [];
|
||||
|
||||
/** @var int[] */
|
||||
private array $possibleLoop = [];
|
||||
|
||||
/**
|
||||
* Read the file.
|
||||
*/
|
||||
@@ -137,7 +140,9 @@ class OLERead
|
||||
|
||||
$sbdBlock = $this->sbdStartBlock;
|
||||
$this->smallBlockChain = '';
|
||||
$this->possibleLoop = [];
|
||||
while ($sbdBlock != -2) {
|
||||
$this->catchLoop($sbdBlock);
|
||||
$pos = ($sbdBlock + 1) * self::BIG_BLOCK_SIZE;
|
||||
|
||||
$this->smallBlockChain .= substr($this->data, $pos, 4 * $bbs);
|
||||
@@ -153,6 +158,14 @@ class OLERead
|
||||
$this->readPropertySets();
|
||||
}
|
||||
|
||||
private function catchLoop(int $sbdBlock): void
|
||||
{
|
||||
if (in_array($sbdBlock, $this->possibleLoop, true)) {
|
||||
throw new ReaderException('Detected loop while iterating blocks');
|
||||
}
|
||||
$this->possibleLoop[] = $sbdBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract binary stream data.
|
||||
*/
|
||||
@@ -172,7 +185,9 @@ class OLERead
|
||||
/** @var int */
|
||||
$block = $this->props[$stream]['startBlock'];
|
||||
|
||||
$this->possibleLoop = [];
|
||||
while ($block != -2) {
|
||||
$this->catchLoop($block);
|
||||
$pos = $block * self::SMALL_BLOCK_SIZE;
|
||||
$streamData .= substr($rootdata, $pos, self::SMALL_BLOCK_SIZE);
|
||||
|
||||
@@ -195,7 +210,9 @@ class OLERead
|
||||
/** @var int */
|
||||
$block = $this->props[$stream]['startBlock'];
|
||||
|
||||
$this->possibleLoop = [];
|
||||
while ($block != -2) {
|
||||
$this->catchLoop($block);
|
||||
$pos = ($block + 1) * self::BIG_BLOCK_SIZE;
|
||||
$streamData .= substr($this->data, $pos, self::BIG_BLOCK_SIZE);
|
||||
$block = self::getInt4d($this->bigBlockChain, $block * 4);
|
||||
@@ -215,7 +232,9 @@ class OLERead
|
||||
{
|
||||
$data = '';
|
||||
|
||||
$this->possibleLoop = [];
|
||||
while ($block != -2) {
|
||||
$this->catchLoop($block);
|
||||
$pos = ($block + 1) * self::BIG_BLOCK_SIZE;
|
||||
$data .= substr($this->data, $pos, self::BIG_BLOCK_SIZE);
|
||||
$block = self::getInt4d($this->bigBlockChain, $block * 4);
|
||||
@@ -231,7 +250,7 @@ class OLERead
|
||||
{
|
||||
$offset = 0;
|
||||
|
||||
// loop through entires, each entry is 128 bytes
|
||||
// loop through entries, each entry is 128 bytes
|
||||
$entryLen = strlen($this->entry);
|
||||
while ($offset < $entryLen) {
|
||||
// entry data (128 bytes)
|
||||
|
||||
Reference in New Issue
Block a user