FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=17813&edit=1

ID: 17813
Updated by: marielyne@acanac.net
Reported By: marielyne at acanac dot net
Summary: Prevent PHP notice when extracting corrupted archive
Status: Open
Type: Feature/Change Request
Package: Archive_Tar
Operating System: Windows 7
Package Version: SVN
PHP Version: 5.3.3
Roadmap Versions:
New Comment:

Obviously..I meant
.' does


Previous Comments:
------------------------------------------------------------------------

[2010-08-24 21:27:10] doumtidilidoom

Description:
------------
I was extracting a corrupted archive and noticed 2 filesize() calls on a
non-existent file

I suggest to either test if the file exists and then cache the value

Caching could also be done in _openAppend()
Is it read immediately and again in the "else" block
Purely an optimisation

Test script:
---------------
// ----- Check the file size
clearstatcache();
if (filesize($v_header['filename']) != $v_header['size']) {
$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.');
return false;
}

Expected result:
----------------
// ----- Check the file size
clearstatcache();
if (!is_file($v_header['filename'])) {
$this->_error('Extracted file '.$v_header['filename']
'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;
}

Actual result:
--------------
*

------------------------------------------------------------------------

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedAug 24, '10 at 9:29p
activeAug 24, '10 at 9:29p
posts1
users1
websitepear.php.net

1 user in discussion

Marielyne: 1 post

People

Translate

site design / logo © 2022 Grokbase