Permalink
Browse files

Request #17813 - Prevent PHP notice when extracting corrupted archive

git-svn-id: https://svn.php.net/repository/pear/packages/Archive_Tar/trunk@304123 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent dc1e995 commit 470ca2c104577db23198163ce227729a1b77c75e @mrook mrook committed Oct 5, 2010
Showing with 12 additions and 5 deletions.
  1. +12 −5 Archive/Tar.php
View
@@ -1679,12 +1679,19 @@ function _extractList($p_path, &$p_list_detail, $p_mode,
// ----- Check the file size
clearstatcache();
- if (filesize($v_header['filename']) != $v_header['size']) {
+ if (!is_file($v_header['filename'])) {
$this->_error('Extracted file '.$v_header['filename']
- .' does not have the correct file size \''
- .filesize($v_header['filename'])
- .'\' ('.$v_header['size']
- .' expected). Archive may be corrupted.');
+ .'does not exist. Archive may be corrupted.');
+ return false;
+ }
+
+ $filesize = filesize($v_header['filename']);
+ if ($filesize != $v_header['size']) {
+ $this->_error('Extracted file '.$v_header['filename']
+ .' does not have the correct file size \''
+ .$filesize
+ .'\' ('.$v_header['size']
+ .' expected). Archive may be corrupted.');
return false;
}
}

0 comments on commit 470ca2c

Please sign in to comment.