function Archive_Tar::_readHeader
6 calls to Archive_Tar::_readHeader()
- Archive_Tar::_extractInString in drupal-7.x/modules/system/system.tar.inc
- This method extract from the archive one file identified by $p_filename.
The return value is a string with the file content, or NULL on error.
- Archive_Tar::_extractInString in drupal-7.x/modules/system/system.tar.inc
- This method extract from the archive one file identified by $p_filename.
The return value is a string with the file content, or NULL on error.
- Archive_Tar::_extractList in drupal-7.x/modules/system/system.tar.inc
- Archive_Tar::_extractList in drupal-7.x/modules/system/system.tar.inc
- Archive_Tar::_readLongHeader in drupal-7.x/modules/system/system.tar.inc
... See full list
Archivo
- drupal-7.x/modules/system/system.tar.inc, line 1277
Class
- Archive_Tar
- Creates a (compressed) Tar archive
*
Código
function _readHeader($v_binary_data, &$v_header) {
if (strlen($v_binary_data) == 0) {
$v_header['filename'] = '';
return true;
}
if (strlen($v_binary_data) != 512) {
$v_header['filename'] = '';
$this->_error('Invalid block size : ' . strlen($v_binary_data));
return false;
}
if (!is_array($v_header)) {
$v_header = array();
}
$v_checksum = 0;
for ($i = 0; $i < 148; $i++) {
$v_checksum += ord(substr($v_binary_data, $i, 1));
};
for ($i = 148; $i < 156; $i++) {
$v_checksum += ord(' ');
};
for ($i = 156; $i < 512; $i++) {
$v_checksum += ord(substr($v_binary_data, $i, 1));
};
$v_data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/" . "a8checksum/a1typeflag/a100link/a6magic/a2version/" . "a32uname/a32gname/a8devmajor/a8devminor", $v_binary_data);
$v_header['checksum'] = OctDec(trim($v_data['checksum']));
if ($v_header['checksum'] != $v_checksum) {
$v_header['filename'] = '';
if (($v_checksum == 256) && ($v_header['checksum'] == 0)) {
return true;
}
$this->_error('Invalid checksum for file "' . $v_data['filename'] . '" : ' . $v_checksum . ' calculated, ' . $v_header['checksum'] . ' expected');
return false;
}
$v_header['filename'] = trim($v_data['filename']);
if ($this->_maliciousFilename($v_header['filename'])) {
$this->_error('Malicious .tar detected, file "' . $v_header['filename'] . '" will not install in desired directory tree');
return false;
}
$v_header['mode'] = OctDec(trim($v_data['mode']));
$v_header['uid'] = OctDec(trim($v_data['uid']));
$v_header['gid'] = OctDec(trim($v_data['gid']));
$v_header['size'] = OctDec(trim($v_data['size']));
$v_header['mtime'] = OctDec(trim($v_data['mtime']));
if (($v_header['typeflag'] = $v_data['typeflag']) == "5") {
$v_header['size'] = 0;
}
$v_header['link'] = trim($v_data['link']);
return true;
}