[PEAR-BUG] Bug #18702 [Opn->Asn]: Unpacks incorrectly on long file names using header prefix

[email protected]
Newsgroups php.pear.bugs
Message-ID <[email protected]>
Edit report at http://pear.php.net/bugs/bug.php?id=18702&edit=1

 ID:               18702
 Updated by:       [email protected]
 Reported By:      landeholm at gmail dot com
 Summary:          Unpacks incorrectly on long file names using header
                    prefix
-Status:           Open
+Status:           Assigned
 Type:             Bug
 Package:          Archive_Tar
 Operating System: Irrelevant
 Package Version:  1.3.7
 PHP Version:      5.3.6
-Roadmap Versions: 
+Roadmap Versions: 1.3.8
 New Comment:

-Status:           Open
+Status:           Assigned
-Roadmap Versions:
+Roadmap Versions: 1.3.8



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

[2011-08-02 23:40:58] hannes_landeholm

Description:
------------
Long file names does not unpack correctly when the prefix field in the
TAR header is set. This is because Archive_Tar ignore that field.

Test script:
---------------
This is a sample tar that has some long image file names that
incorrectly get extracted to root rather than into their target
directory: https://github.com/melt/melt/tarball/1.0

Here is the patch I used which fixed the problem:

@@ -1314,8 +1314,10 @@
 
         $v_data =
unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/"
 		                
."a8checksum/a1typeflag/a100link/a6magic/a2version/"
-						 ."a32uname/a32gname/a8devmajor/a8devminor",
+						 ."a32uname/a32gname/a8devmajor/a8devminor/a131prefix",
 						 $v_binary_data);
+        if (strlen($v_data["prefix"]) > 0)
+            $v_data["filename"] = "$v_data[prefix]/$v_data[filename]";
 
         // ----- Extract the checksum
         $v_header['checksum'] = OctDec(trim($v_data['checksum']));

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


-- 
Edit this bug report at http://pear.php.net/bugs/bug.php?id=18702&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.