Req #17813 [Opn]: Prevent PHP notice when extracting corrupted archive

From: Date: Tue, 24 Aug 2010 21:29:37 +0000
Subject: Req #17813 [Opn]: Prevent PHP notice when extracting corrupted archive
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to pear-bugs+get-4658@lists.php.net to get a copy of this message
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: -------------- * ------------------------------------------------------------------------ -- Edit this bug report at http://pear.php.net/bugs/bug.php?id=17813&edit=1

« previous php.pear.bugs (#4658) next »