Skip to content

Commit 871eb5c

Browse files
committed
Issue #3026470 by alexpott, jrockowitz, Joseph Zhao: ArchiveTar is throwing fatal error
(cherry picked from commit b0a6389)
1 parent 4c59417 commit 871eb5c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/Drupal/Core/Archiver/ArchiveTar.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ class ArchiveTar
157157
* @var string
158158
*/
159159
public $_fmt ='';
160-
161160
/**
162161
* Archive_Tar Class constructor. This flavour of the constructor only
163162
* declare a new Archive_Tar object, identifying it by the name of the
@@ -265,6 +264,7 @@ public function __construct($p_tarname, $p_compress = null)
265264
}
266265
}
267266

267+
268268
if (version_compare(PHP_VERSION, "5.5.0-dev") < 0) {
269269
$this->_fmt = "a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/" .
270270
"a8checksum/a1typeflag/a100link/a6magic/a2version/" .
@@ -1411,6 +1411,7 @@ public function _writeHeader($p_filename, $p_stored_filename)
14111411
if ($p_stored_filename == '') {
14121412
$p_stored_filename = $p_filename;
14131413
}
1414+
14141415
$v_reduced_filename = $this->_pathReduction($p_stored_filename);
14151416

14161417
if (strlen($v_reduced_filename) > 99) {
@@ -1423,6 +1424,7 @@ public function _writeHeader($p_filename, $p_stored_filename)
14231424
if (@is_link($p_filename)) {
14241425
$v_linkname = readlink($p_filename);
14251426
}
1427+
14261428
if (strlen($v_linkname) > 99) {
14271429
if (!$this->_writeLongHeader($v_linkname, true)) {
14281430
return false;
@@ -1463,11 +1465,11 @@ public function _writeHeader($p_filename, $p_stored_filename)
14631465

14641466
$v_devmajor = '';
14651467
$v_devminor = '';
1466-
14671468
$v_prefix = '';
14681469

14691470
$v_binary_data_first = pack(
14701471
"a100a8a8a8a12a12",
1472+
$v_reduced_filename,
14711473
$v_perms,
14721474
$v_uid,
14731475
$v_gid,
@@ -1740,6 +1742,7 @@ public function _readHeader($v_binary_data, &$v_header)
17401742
$v_checksum += array_sum(array_map('ord', array(' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',)));
17411743
$v_checksum += array_sum(array_map('ord', array_slice($v_binary_split, 156, 512)));
17421744

1745+
17431746
$v_data = unpack($this->_fmt, $v_binary_data);
17441747

17451748
if (strlen($v_data["prefix"]) > 0) {
@@ -1829,7 +1832,6 @@ private function _tarRecToSize($tar_size)
18291832
}
18301833
}
18311834

1832-
18331835
/**
18341836
* Detect and report a malicious file name
18351837
*

0 commit comments

Comments
 (0)