From:  pear-qa@lists.php.net ("aparcos@gmail.com")
Date:  20 Sep 2018 22:50:25 Hong Kong Time
Newsgroup:  news.php.net/php.pear.bugs
Subject:  

[PEAR-BUG] Bug #23769 [Com]: Archive_Tar in Tar::extractList fails to get file

NNTP-Posting-Host:  null

Edit report at https://pear.php.net/bugs/bug.php?id=23769&edit=1

 ID:               23769
 Comment by:       aparcos at gmail dot com
 Reported By:      aparcos at gmail dot com
 Summary:          Archive_Tar in Tar::extractList fails to get file
 Status:           Open
 Type:             Bug
 Package:          Archive_Tar
 Operating System: Windows
 Package Version:  1.4.3
 PHP Version:      Irrelevant
 Roadmap Versions: 
 New Comment:

I have changed build.php

==== build.php to create the structure and files is going to generate 
 0) {
	mkdir($subfolder=uniqid());
	chdir($subfolder);

	$numFiles = 20000;
	while($numFiles-- > 0) {
		createFile('file-' . uniqid(), 1024, $blocks);
	}
	chdir('../');
}

$subFolderCounter = 36;
while ($subFolderCounter-- > 0) {	
	mkdir($subfolder=uniqid());
	chdir($subfolder);
	
	$numSizeTotal = 40 * 1024 * 1024;
	while($numSizeTotal > 0) {
		createFile('file-big-' . uniqid(), $size = rand(15, 20) * 1024 *1024,
$blocks);
		$numSizeTotal -= $size;
	}
	chdir('../');
}

// Create a json file
file_put_contents('file.json', json_encode(['thisAObject' => 0]));

chdir('../');

echo 'Done!', PHP_EOL;


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

[2018-09-20 10:36:20] aparcos

-Status: Feedback
+Status: Open
Hi Michiel,

I have done some scripts to reproduce it.



==== build.php to create the structure and files is going to generate 
 0) {
	mkdir($subfolder=uniqid());
	chdir($subfolder);

	$numFiles = 20000;
	while($numFiles-- > 0) {
		createFile('file-' . uniqid(), 1024, $blocks);
	}
	chdir('../');
}

$subFolderCounter = 36;
while ($subFolderCounter-- > 0) {	
	mkdir($subfolder=uniqid());
	chdir($subfolder);
	
	$numSizeTotal = 40 * 1024 * 1024;
	while($numSizeTotal-- > 0) {
		createFile('file-big-' . uniqid(), $size = rand(15, 20) * 1024 *1024,
$blocks);
		$numSizeTotal -= $size;
	}
	chdir('../');
}

// Create a json file
file_put_contents('file.json', json_encode(['thisAObject' => 0]));

chdir('../');

echo 'Done!', PHP_EOL;


==== tar_build.php to generate the whole tar files 

extractList([$filename]);

if ($tar->error_object !== null) {
        // We found the issue :(
        echo 'Message from error_object: ' . 
$tar->error_object->message, PHP_EOL;
        exit(0);
}

if (file_exists($filename)) {
        // We noy found the issue :)
        echo 'Oops, the file was extracted', PHP_EOL;
        echo file_get_contents($filename);
        unlink($filename);
} 


==== You shouldn't see some message like:

$ php get.php
Message from error_object: Invalid checksum for file
"nopabcdefghmnopmnopabcdefg
hmnopmnopabcdefghmnopmnopabcdefghmnopmnopabcdefghmnopmnopabcdefghmnopmnopabcdefg
hmnopmnopabcdefghmnopmnop/efghmnopmnopabcdefghmnopmnopabcdefghmnopmnopabcdefghmn
opmnopabcdefghmnopmnopabcdefghmnopmnopabcdefgh" : 53388 calculated, 0
expected


Some more comments. I realized could be caused for the number of files
but i am not sure, i have seen for the whole size of the build folder is
created (for me is 2171207697 bytes)

I hope these scripts help to see the real issue.

Thanks!! \o

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

[2018-09-19 13:54:10] mrook

-Status: Open
+Status: Feedback
We are unable to reproduce the bug as reported.
Please provide a simple script (10 lines or less)
or a link to an external script that can be used
to reproduce the bug.

If you can provide the script, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PEAR.


Do you have a .tar file I can use to reproduce this?

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

[2018-09-19 11:31:09] aparcos

Description:
------------
I have an issue with this library:

Method Tar:extractList cannot get a file when the size of uncompressed
whole files are 2117952732 bytes

this->error_object contains the error message

Invalid checksum for file "global!=="undefined"){g=global}else if(typeof
self!=="undefined"){g=self}else{g=this}g.Plotly = f()}})(function(){var
define,module//**
* plotly.js (gl3d) v1.24.2
* Copyright 2012-2017, Plotly, Inc.
* All rights reserved.
* Licensed" : 44975 calculated, 0 expected


Where file should be a correct filename but it is the content (or
rubissh from a bad offset, i think, not sure)

Could you check it also for me?

I have used Archive_Tar Pear library version 1.4.3 with PHP 7.2.5
(64bits)

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


-- 
Edit this bug report at https://pear.php.net/bugs/bug.php?id=23769&edit=1