Codex's updates...

This commit is contained in:
2026-10-18 19:27:17 -04:00
parent a1643eb1b7
commit 02223083f6
338 changed files with 14757 additions and 7986 deletions
@@ -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)