From: Matthias Schmidt Date: Mon, 27 Feb 2012 17:35:26 +0000 (+0100) Subject: Fixes bug involving long file names in tarballs X-Git-Tag: 2.0.0_Beta_1~1299^2~2^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=421f47491cdf3bfc9c13e6bb5f854f28f85d59c2;p=GitHub%2FWoltLab%2FWCF.git Fixes bug involving long file names in tarballs --- diff --git a/wcfsetup/install/files/lib/system/io/Tar.class.php b/wcfsetup/install/files/lib/system/io/Tar.class.php index 7ac9596179..0ef0b1006d 100644 --- a/wcfsetup/install/files/lib/system/io/Tar.class.php +++ b/wcfsetup/install/files/lib/system/io/Tar.class.php @@ -269,15 +269,31 @@ class Tar { $i = 0; // Read the 512 bytes header + $longFilename = null; while (strlen($binaryData = $this->file->read(512)) != 0) { // read header $header = $this->readHeader($binaryData); if ($header === false) { continue; } - $this->contentList[$i] = $header; - $this->contentList[$i]['index'] = $i; - $i++; + + // fixes a bug that files with long names aren't correctly + // extracted + if ($longFilename !== null) { + $header['filename'] = $longFilename; + $longFilename = null; + } + if ($header['typeflag'] == 'L') { + $fileData = unpack("a".$header['size']."filename", $this->file->read(512)); + $longFilename = $fileData['filename']; + $header['size'] = 0; + } + // don't include the @LongLink file in the content list + else { + $this->contentList[$i] = $header; + $this->contentList[$i]['index'] = $i; + $i++; + } $this->file->seek($this->file->tell() + (512 * ceil(($header['size'] / 512)))); }