Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"nikic/php-parser": "^4.2",
"patchwork/jsqueeze": "^2.0",
"patchwork/utf8": "1.3.1",
"pear/archive_tar": "1.4.8",
"pear/archive_tar": "1.4.11",
"pear/pear-core-minimal": "^v1.10",
"phpseclib/phpseclib": "2.0.23",
"php-opencloud/openstack": "3.0.6",
Expand Down
23 changes: 15 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion composer/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ClassLoader
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}

return array();
Expand Down
3 changes: 3 additions & 0 deletions composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public static function loadClassLoader($class)
}
}

/**
* @return \Composer\Autoload\ClassLoader
*/
public static function getLoader()
{
if (null !== self::$loader) {
Expand Down
12 changes: 6 additions & 6 deletions composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -2094,17 +2094,17 @@
},
{
"name": "pear/archive_tar",
"version": "1.4.8",
"version_normalized": "1.4.8.0",
"version": "1.4.11",
"version_normalized": "1.4.11.0",
"source": {
"type": "git",
"url": "https://github.com/pear/Archive_Tar.git",
"reference": "442bdffb7edb84c898cfd94f7ac8500e49d5bbb5"
"reference": "17d355cb7d3c4ff08e5729f29cd7660145208d9d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pear/Archive_Tar/zipball/442bdffb7edb84c898cfd94f7ac8500e49d5bbb5",
"reference": "442bdffb7edb84c898cfd94f7ac8500e49d5bbb5",
"url": "https://api.github.com/repos/pear/Archive_Tar/zipball/17d355cb7d3c4ff08e5729f29cd7660145208d9d",
"reference": "17d355cb7d3c4ff08e5729f29cd7660145208d9d",
"shasum": ""
},
"require": {
Expand All @@ -2119,7 +2119,7 @@
"ext-xz": "Lzma2 compression support.",
"ext-zlib": "Gzip compression support."
},
"time": "2019-10-21T13:31:24+00:00",
"time": "2020-11-19T22:10:24+00:00",
"type": "library",
"extra": {
"branch-alias": {
Expand Down
5 changes: 5 additions & 0 deletions pear/archive_tar/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ vendor
.buildpath
.project
.settings
# pear
.tarballs
*.tgz
# phpunit
build
49 changes: 34 additions & 15 deletions pear/archive_tar/Archive/Tar.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,12 @@ public function add($p_filelist)
/**
* @param string $p_path
* @param bool $p_preserve
* @param bool $p_symlinks
* @return bool
*/
public function extract($p_path = '', $p_preserve = false)
public function extract($p_path = '', $p_preserve = false, $p_symlinks = true)
{
return $this->extractModify($p_path, '', $p_preserve);
return $this->extractModify($p_path, '', $p_preserve, $p_symlinks);
}

/**
Expand Down Expand Up @@ -557,11 +558,12 @@ public function addString($p_filename, $p_string, $p_datetime = false, $p_params
* removed if present at the beginning of
* the file/dir path.
* @param boolean $p_preserve Preserve user/group ownership of files
* @param boolean $p_symlinks Allow symlinks.
*
* @return boolean true on success, false on error.
* @see extractList()
*/
public function extractModify($p_path, $p_remove_path, $p_preserve = false)
public function extractModify($p_path, $p_remove_path, $p_preserve = false, $p_symlinks = true)
{
$v_result = true;
$v_list_detail = array();
Expand All @@ -573,7 +575,8 @@ public function extractModify($p_path, $p_remove_path, $p_preserve = false)
"complete",
0,
$p_remove_path,
$p_preserve
$p_preserve,
$p_symlinks
);
$this->_close();
}
Expand Down Expand Up @@ -617,11 +620,12 @@ public function extractInString($p_filename)
* removed if present at the beginning of
* the file/dir path.
* @param boolean $p_preserve Preserve user/group ownership of files
* @param boolean $p_symlinks Allow symlinks.
*
* @return true on success, false on error.
* @see extractModify()
*/
public function extractList($p_filelist, $p_path = '', $p_remove_path = '', $p_preserve = false)
public function extractList($p_filelist, $p_path = '', $p_remove_path = '', $p_preserve = false, $p_symlinks = true)
{
$v_result = true;
$v_list_detail = array();
Expand All @@ -642,7 +646,8 @@ public function extractList($p_filelist, $p_path = '', $p_remove_path = '', $p_p
"partial",
$v_list,
$p_remove_path,
$p_preserve
$p_preserve,
$p_symlinks
);
$this->_close();
}
Expand Down Expand Up @@ -726,7 +731,7 @@ public function setIgnoreRegexp($regexp)
*/
public function setIgnoreList($list)
{
$regexp = str_replace(array('#', '.', '^', '$'), array('\#', '\.', '\^', '\$'), $list);
$list = str_replace(array('#', '.', '^', '$'), array('\#', '\.', '\^', '\$'), $list);
$regexp = '#/' . join('$|/', $list) . '#';
$this->setIgnoreRegexp($regexp);
}
Expand Down Expand Up @@ -1268,7 +1273,7 @@ public function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $v_
while (($v_buffer = fread($v_file, $this->buffer_length)) != '') {
$buffer_length = strlen("$v_buffer");
if ($buffer_length != $this->buffer_length) {
$pack_size = ((int)($buffer_length / 512) + 1) * 512;
$pack_size = ((int)($buffer_length / 512) + ($buffer_length % 512 !== 0 ? 1 : 0)) * 512;
$pack_format = sprintf('a%d', $pack_size);
} else {
$pack_format = sprintf('a%d', $this->buffer_length);
Expand Down Expand Up @@ -1510,8 +1515,13 @@ public function _writeHeaderBlock(
$userinfo = posix_getpwuid($p_uid);
$groupinfo = posix_getgrgid($p_gid);

$v_uname = $userinfo['name'];
$v_gname = $groupinfo['name'];
if ($userinfo === false || $groupinfo === false) {
$v_uname = '';
$v_gname = '';
} else {
$v_uname = $userinfo['name'];
$v_gname = $groupinfo['name'];
}
} else {
$v_uname = '';
$v_gname = '';
Expand Down Expand Up @@ -1720,7 +1730,7 @@ public function _readHeader($v_binary_data, &$v_header)

// ----- Extract the properties
$v_header['filename'] = rtrim($v_data['filename'], "\0");
if ($this->_maliciousFilename($v_header['filename'])) {
if ($this->_isMaliciousFilename($v_header['filename'])) {
$this->_error(
'Malicious .tar detected, file "' . $v_header['filename'] .
'" will not install in desired directory tree'
Expand Down Expand Up @@ -1790,9 +1800,9 @@ private function _tarRecToSize($tar_size)
*
* @return bool
*/
private function _maliciousFilename($file)
private function _isMaliciousFilename($file)
{
if (strpos($file, 'phar://') === 0) {
if (strpos($file, '://') !== false) {
return true;
}
if (strpos($file, '../') !== false || strpos($file, '..\\') !== false) {
Expand Down Expand Up @@ -1828,7 +1838,7 @@ public function _readLongHeader(&$v_header)

$v_filename = rtrim(substr($v_filename, 0, $v_filesize), "\0");
$v_header['filename'] = $v_filename;
if ($this->_maliciousFilename($v_filename)) {
if ($this->_isMaliciousFilename($v_filename)) {
$this->_error(
'Malicious .tar detected, file "' . $v_filename .
'" will not install in desired directory tree'
Expand Down Expand Up @@ -1917,6 +1927,7 @@ private function _extractInString($p_filename)
* @param string $p_file_list
* @param string $p_remove_path
* @param bool $p_preserve
* @param bool $p_symlinks
* @return bool
*/
public function _extractList(
Expand All @@ -1925,7 +1936,8 @@ public function _extractList(
$p_mode,
$p_file_list,
$p_remove_path,
$p_preserve = false
$p_preserve = false,
$p_symlinks = true
)
{
$v_result = true;
Expand Down Expand Up @@ -2108,6 +2120,13 @@ public function _extractList(
}
}
} elseif ($v_header['typeflag'] == "2") {
if (!$p_symlinks) {
$this->_warning('Symbolic links are not allowed. '
. 'Unable to extract {'
. $v_header['filename'] . '}'
);
return false;
}
if (@file_exists($v_header['filename'])) {
@unlink($v_header['filename']);
}
Expand Down
Loading