function ArchiveTar::_readLongHeader

2 calls to ArchiveTar::_readLongHeader()
ArchiveTar::_extractInString in drupal/core/lib/Drupal/Component/Archiver/ArchiveTar.php
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.
ArchiveTar::_extractList in drupal/core/lib/Drupal/Component/Archiver/ArchiveTar.php

File

drupal/core/lib/Drupal/Component/Archiver/ArchiveTar.php, line 1380

Class

ArchiveTar
Creates a (compressed) Tar archive

Namespace

Drupal\Component\Archiver

Code

function _readLongHeader(&$v_header) {
  $v_filename = '';
  $n = floor($v_header['size'] / 512);
  for ($i = 0; $i < $n; $i++) {
    $v_content = $this
      ->_readBlock();
    $v_filename .= $v_content;
  }
  if ($v_header['size'] % 512 != 0) {
    $v_content = $this
      ->_readBlock();
    $v_filename .= $v_content;
  }

  // ----- Read the next header
  $v_binary_data = $this
    ->_readBlock();
  if (!$this
    ->_readHeader($v_binary_data, $v_header)) {
    return false;
  }
  $v_filename = trim($v_filename);
  $v_header['filename'] = $v_filename;
  if ($this
    ->_maliciousFilename($v_filename)) {
    $this
      ->_error('Malicious .tar detected, file "' . $v_filename . '" will not install in desired directory tree');
    return false;
  }
  return true;
}