Skip to content

Commit

Permalink
Merge pull request #52 from mateusz/just-message
Browse files Browse the repository at this point in the history
Raise an error for archives over 8 GB to prevent weird checksum errors.
  • Loading branch information
Sean Harvey committed Dec 22, 2016
2 parents f4a48e0 + 2dd54e5 commit a101ca0
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/SSPak.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,32 @@ function extract($args) {
$file = $unnamedArgs[0];
$dest = !empty($unnamedArgs[1]) ? $unnamedArgs[1] : getcwd();

// Phar and PharData use "ustar" format for tar archives (http://php.net/manual/pl/phar.fileformat.tar.php).
// Ustar does not support files larger than 8 GB.
// If the sspak has been created through tar and gz directly, it will probably be in POSIX, PAX or GNU formats,
// which do support >8 GB files. Such archive cannot be accessed by Phar/PharData, and needs to be handled
// manually - it will just spew checksum errors where PHP expects to see ustar headers, but finds garbage
// from other formats.
// There is no cross-platform way of checking the assets.tar.gz size without unpacking, so we assume the size
// of database is negligible which lets us approximate the size of assets.
if (filesize($file) > 8*1024*1024*1024) {
$msg = <<<EOM
ERROR: SSPak is unable to extract archives over 8 GB.
Packed asset or database sizes over 8 GB are not supported due to PHP Phar library limitations.
You can still access your data directly by using the tar utility:
tar xzf "%s"
This tool is sorry for the inconvenience and stands aside in disgrace.
See http://silverstripe.github.io/sspak/, "Manual access" for more information.
EOM;
printf($msg, $file);
die(1);
}

$sspak = new SSPakFile($file, $executor);

// Validation
Expand Down

0 comments on commit a101ca0

Please sign in to comment.