Fixed issue when creating a shadow copy of a package, if the universe aligns together and the cosmos unit together to
produce a package length exactly to where the end-of-package byte sequence is cut in half, the shadow copy will fail to be created due to the end-of-package byte sequence being cut in half, this issue was fixed by reading the package in chunks to determine the end-of-package byte sequence. The PackageReader class has been updated to use a more efficient buffer management when reading data from a file. Previously, buffer size was growing uncontrollably and can eventually lead to out-of-memory errors for large files. Now, the data is read in chunks and the buffer is cleared when it exceeds approximately 1MB size, maintaining only the last 512KB. This change ensures a more memory-efficient package reading and effectively prevents erroneous deadlocks for large package files. Additionally, detection for end-of-data byte sequence has been modified to rectify an issue where package length could cut off the end-of-package byte sequence. This results in an improved reliability for package validation.
This commit is contained in:
parent
76f12bb0a3
commit
d2635b19fd
2 changed files with 17 additions and 2 deletions
|
@ -29,6 +29,10 @@ This update introduces minor bug fixes.
|
|||
- Fixed issue where all development dependencies were not correctly being added to debug builds in composer projects,
|
||||
instead these dependencies were added globally to the build configuration. This issue was fixed by adding all the
|
||||
development dependencies to the debug build configurations only.
|
||||
- Fixed issue when creating a shadow copy of a package, if the universe aligns together and the cosmos unit together to
|
||||
produce a package length exactly to where the end-of-package byte sequence is cut in half, the shadow copy will fail
|
||||
to be created due to the end-of-package byte sequence being cut in half, this issue was fixed by reading the package
|
||||
in chunks to determine the end-of-package byte sequence.
|
||||
|
||||
|
||||
## [2.0.3] - 2023-10-17
|
||||
|
|
|
@ -182,17 +182,28 @@
|
|||
|
||||
// Seek the data until the end of the package (FF AA 55 F0)
|
||||
fseek($this->package_file, $this->data_offset);
|
||||
$buffer = '';
|
||||
while(!feof($this->package_file))
|
||||
{
|
||||
$buffer = fread($this->package_file, 1024);
|
||||
$this->data_length += strlen($buffer);
|
||||
$current_chunk = fread($this->package_file, 1024);
|
||||
$this->data_length += strlen($current_chunk);
|
||||
$buffer .= $current_chunk;
|
||||
|
||||
// If we detect the end-of-data byte sequence
|
||||
if (($position = strpos($buffer, "\xFF\xAA\x55\xF0")) !== false)
|
||||
{
|
||||
$this->data_length -= strlen($buffer) - $position;
|
||||
$this->package_length += $this->data_length + 4;
|
||||
break;
|
||||
}
|
||||
|
||||
// Check if the buffer is 1MB or larger
|
||||
if(strlen($buffer) > 1048576)
|
||||
{
|
||||
// Remove the first 512kb of the buffer
|
||||
$buffer = substr($buffer, 512000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($this->data_length === null || $this->data_length === 0)
|
||||
|
|
Loading…
Add table
Reference in a new issue