1 |
1 |
<?php
|
2 |
|
/* vim: set ts=4 sw=4: */
|
3 |
|
// +----------------------------------------------------------------------+
|
4 |
|
// | PHP Version 4 |
|
5 |
|
// +----------------------------------------------------------------------+
|
6 |
|
// | Copyright (c) 1997-2003 The PHP Group |
|
7 |
|
// +----------------------------------------------------------------------+
|
8 |
|
// | This source file is subject to version 3.0 of the PHP license, |
|
9 |
|
// | that is bundled with this package in the file LICENSE, and is |
|
10 |
|
// | available through the world-wide-web at the following url: |
|
11 |
|
// | http://www.php.net/license/3_0.txt. |
|
12 |
|
// | If you did not receive a copy of the PHP license and are unable to |
|
13 |
|
// | obtain it through the world-wide-web, please send a note to |
|
14 |
|
// | license@php.net so we can mail you a copy immediately. |
|
15 |
|
// +----------------------------------------------------------------------+
|
16 |
|
// | Author: Vincent Blavet <vincent@phpconcept.net> |
|
17 |
|
// +----------------------------------------------------------------------+
|
18 |
|
//
|
19 |
|
// $Id: Tar.php,v 1.39 2006/12/22 19:20:08 cellog Exp $
|
|
2 |
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
|
3 |
|
|
4 |
/**
|
|
5 |
* File::CSV
|
|
6 |
*
|
|
7 |
* PHP versions 4 and 5
|
|
8 |
*
|
|
9 |
* Copyright (c) 1997-2008,
|
|
10 |
* Vincent Blavet <vincent@phpconcept.net>
|
|
11 |
* All rights reserved.
|
|
12 |
*
|
|
13 |
* Redistribution and use in source and binary forms, with or without
|
|
14 |
* modification, are permitted provided that the following conditions are met:
|
|
15 |
*
|
|
16 |
* * Redistributions of source code must retain the above copyright notice,
|
|
17 |
* this list of conditions and the following disclaimer.
|
|
18 |
* * Redistributions in binary form must reproduce the above copyright
|
|
19 |
* notice, this list of conditions and the following disclaimer in the
|
|
20 |
* documentation and/or other materials provided with the distribution.
|
|
21 |
*
|
|
22 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
23 |
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
24 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
25 |
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
|
26 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
27 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
28 |
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
29 |
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
30 |
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
31 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
32 |
*
|
|
33 |
*
|
|
34 |
* @category File_Formats
|
|
35 |
* @package Archive_Tar
|
|
36 |
* @author Vincent Blavet <vincent@phpconcept.net>
|
|
37 |
* @copyright 1997-2008 The Authors
|
|
38 |
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
|
|
39 |
* @version CVS: $Id$
|
|
40 |
* @link http://pear.php.net/package/Archive_Tar
|
|
41 |
*/
|
20 |
42 |
|
21 |
43 |
require_once 'PEAR.php';
|
22 |
44 |
|
... | ... | |
29 |
51 |
*
|
30 |
52 |
* @author Vincent Blavet <vincent@phpconcept.net>
|
31 |
53 |
* @version $Revision: 1.39 $
|
32 |
|
* @package Archive
|
|
54 |
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
|
|
55 |
* @package Archive_Tar
|
33 |
56 |
*/
|
34 |
57 |
class Archive_Tar extends PEAR
|
35 |
58 |
{
|
... | ... | |
1254 |
1277 |
}
|
1255 |
1278 |
|
1256 |
1279 |
// ----- Extract the properties
|
1257 |
|
$v_header['filename'] = trim($v_data['filename']);
|
|
1280 |
$v_header['filename'] = $v_data['filename'];
|
1258 |
1281 |
if ($this->_maliciousFilename($v_header['filename'])) {
|
1259 |
1282 |
$this->_error('Malicious .tar detected, file "' . $v_header['filename'] .
|
1260 |
1283 |
'" will not install in desired directory tree');
|
... | ... | |
1314 |
1337 |
}
|
1315 |
1338 |
if (($v_header['size'] % 512) != 0) {
|
1316 |
1339 |
$v_content = $this->_readBlock();
|
1317 |
|
$v_filename .= $v_content;
|
|
1340 |
$v_filename .= trim($v_content);
|
1318 |
1341 |
}
|
1319 |
1342 |
|
1320 |
1343 |
// ----- Read the next header
|
... | ... | |
1323 |
1346 |
if (!$this->_readHeader($v_binary_data, $v_header))
|
1324 |
1347 |
return false;
|
1325 |
1348 |
|
|
1349 |
$v_filename = trim($v_filename);
|
1326 |
1350 |
$v_header['filename'] = $v_filename;
|
1327 |
1351 |
if ($this->_maliciousFilename($v_filename)) {
|
1328 |
1352 |
$this->_error('Malicious .tar detected, file "' . $v_filename .
|