php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58092 Extra chars following content in tar
Submitted: 2008-03-08 22:49 UTC Modified: 2008-04-29 05:27 UTC
From: sfox@php.net Assigned:
Status: Closed Package: phar (PECL)
PHP Version: 5_2 CVS-2008-03-08 OS: win32
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sfox@php.net
New email:
PHP Version: OS:

 

 [2008-03-08 22:49 UTC] sfox@php.net
Description:
------------
I'm seeing extra characters stuffed into the end of files 'tarred' using ext/phar (both Phar and PharData). I don't _think_ this is normal because tar -xf complains about it when run directly:

C:\sandbox\php5\Debug_TS>tar -xf myphar.phar.tar
tar: Unexpected EOF on archive file
tar: Error exit delayed from previous errors

Zip's fine, I can't tell about Phar but it appears OK.

Reproduce code:
---------------
<?php

$fname = dirname(__FILE__) . '/myphar.phar.tar';
$phar = new Phar($fname);
$phar->setAlias('myphar');
$phar['index.php'] = '<?php echo "hello world\n"; ?>';
$phar['bulk.txt'] = str_repeat('a', 8000);

$bulk = file_get_contents('phar://myphar/bulk.txt');
var_dump(strlen($bulk));

system("tar -xf $fname");
$bulk = file_get_contents('bulk.txt');
var_dump(strlen($bulk));

?>

Expected result:
----------------
int(8000)
int(8000)

Actual result:
--------------
int(8000)
int(9216)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-22 18:25 UTC] greg at chiaraquartet dot net
Can't reproduce on 64-bit linux, this happens on windows only?

cellog@lot-49:~/workspace/php52/ext/phar$ ../../sapi/cli/php -c ../../php.ini -dphar.readonly=0 tests/tar/bug13353.phpt
--TEST--
Phar: Bug #13353 extra characters at end of tar
--SKIPIF--
--INI--
phar.readonly=0
--TEST--
int(8000)
int(8000)
--CLEAN--
--EXPECT--
int(8000)
int(8000)
 [2008-03-22 20:41 UTC] sfox@php.net
It may well only happen under doze, but it's still a problem :\

We need others to test this too.
 [2008-04-25 12:57 UTC] greg at chiaraquartet dot net
does this still happen?
 [2008-04-26 09:06 UTC] sfox@php.net
Nope, I'm still seeing the same output from the original script:

C:\sandbox\php5\Debug_TS>php bug.php
int(8000)
int(9216)
 [2008-04-29 05:27 UTC] sfox@php.net
All systems go :)

Note for future reference/other PECLers: this was just one symptom of write corruption caused by the inappropriate use of strcpy(). Other symptoms included borked timestamps and file/dir flags in archived applications. Moving to strncpy() resolved this.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 01:01:28 2024 UTC