Home » File Formats » Archive_Tar » Bug #2135
Does not handle non-sequential file list indexes
Details
| Submitted | 2004-08-16 17:43 UTC |
|---|---|
| From | mjohnson at pitsco dot com |
| Assigned | vblavet |
| Status | Closed |
| Package | Archive_Tar |
| PHP Version | Irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2004-08-16 17:43 UTC] mjohnson at pitsco dot com
Description:
------------
When suppling a list of files in an array that does not use sequential numerical indexes, the files packaged do not necessarily match those requested.
Reproduce code:
---------------
$files = array('one', 'two');
$files[3] = 'three';
$pkg = new Archive_Tar('pkg.tar');
$pkg->create($files);
Patch:
--- Tar.orig.php 2004-08-16 12:35:37.000000000 -0500
+++ Tar.php 2004-08-16 12:38:23.000000000 -0500
@@ -804,8 +804,11 @@
if (sizeof($p_list) == 0)
return true;
- for ($j=0; ($j<count($p_list)) && ($v_result); $j++) {
- $v_filename = $p_list[$j];
+ foreach ($p_list as $v_filename) {
+ if (!$v_result) {
+ break;
+ }
+ //$v_filename = $p_list[$j];
// ----- Skip the current tar name
if ($v_filename == $this->_tarname)
Expected result:
----------------
A tar file with the files one, two, and three
Actual result:
--------------
A tar file with the files one and two, along with
Notice: Undefined offset: 2 in /usr/local/lib/php/Archive/Tar.php on line 808
[2004-08-16 18:07 UTC] mjohnson at pitsco dot com
The actual patch is as follows. I mistakenly sent an earlier version.
--- Tar.orig.php 2004-08-16 12:35:37.000000000 -0500
+++ Tar.php 2004-08-16 13:04:46.000000000 -0500
@@ -804,8 +804,10 @@
if (sizeof($p_list) == 0)
return true;
- for ($j=0; ($j<count($p_list)) && ($v_result); $j++) {
- $v_filename = $p_list[$j];
+ foreach ($p_list as $v_filename) {
+ if (!$v_result) {
+ break;
+ }
// ----- Skip the current tar name
if ($v_filename == $this->_tarname)