php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69750 getStream() partial extract 4MB only
Submitted: 2015-06-03 09:39 UTC Modified: 2017-07-30 04:22 UTC
Votes:5
Avg. Score:4.2 ± 1.0
Reproduced:4 of 4 (100.0%)
Same Version:3 (75.0%)
Same OS:3 (75.0%)
From: vangog at gmail dot com Assigned: cataphract (profile)
Status: No Feedback Package: rar (PECL)
PHP Version: 5.4.41 OS: Debian 3.2.68-1+deb7u1
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-06-03 09:39 UTC] vangog at gmail dot com
Description:
------------
getStream() return stream, which allows to read only (4194304) 4MB data. 
The same entry can be successfully extracted to disk using extract() method. 
Archive was tested on different OS, file was extracted using different software all is ok. This second time I'm reporting this because noticed magic number 4194304 which clearly indicates a bug. 

Also uploaded original file to Google Drive. 

Test script:
---------------
<?php

$remote_path = 'https://drive.google.com/uc?export=download&id=0B6ulFGsiVVF3MkhOTGVEYmxhcFU';
$local_path = sys_get_temp_dir().DIRECTORY_SEPARATOR.'buggy.rar';
if(!file_exists($local_path)){
 copy($remote_path,$local_path);
}

$rar = RarArchive::open($local_path);
$rar->setAllowBroken(true);
$entries = $rar->getEntries();

$entry	= $rar->getEntry('08-twisted_sister-deck_the_halls.mp3');
$declared_size	=	$entry->getUnpackedSize();
$declared_crc	=	$entry->getCrc();
$declared_name	=	$entry->getName();

echo "Expected:\t Size:{$declared_size}\tHash:{$declared_crc}\n";

// Extract item to disk
$extracted_path	= sys_get_temp_dir().DIRECTORY_SEPARATOR.'extracted';
$entry->extract(false, $extracted_path);
$extracted_size	= filesize($extracted_path);
$extracted_hash	= hash_file('crc32b',$extracted_path);
echo "Extracted:\t Size:{$extracted_size}\tHash:{$extracted_hash}\n";

// "Stream" file
$stream		=	$entry->getStream();
$stream_path	=	sys_get_temp_dir().DIRECTORY_SEPARATOR.'stream';
$stream_fp	=	fopen($stream_path,'w');
stream_copy_to_stream($stream,$stream_fp);
$stram_size	=	filesize($stream_path);
$stram_hash	=	hash_file('crc32b',$stream_path);
echo "Stream:\t\t Size:{$stram_size}\tHash:{$stram_hash}\n";

echo "\nVery strange number {$stram_size} = ",$stram_size/1024/1024,'MB which clearly indicates a bug',PHP_EOL;
echo "PHP \t",phpversion(),PHP_EOL;
echo "OS \t",php_uname(),PHP_EOL;

exit;

Expected result:
----------------
Expected:        Size:5069304   Hash:a7bab6b3
Extracted:       Size:5069304   Hash:a7bab6b3
Stream:          Size:5069304   Hash:a7bab6b3


Actual result:
--------------
Expected:        Size:5069304   Hash:a7bab6b3
Extracted:       Size:5069304   Hash:a7bab6b3
Stream:          Size:4194304   Hash:51ccf6cb


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-03 10:36 UTC] tony2001@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: tony2001
 [2016-04-21 15:21 UTC] vangog at gmail dot com
Google drive changed link, so be so kind to download it manually 
https://drive.google.com/file/d/0B6ulFGsiVVF3MkhOTGVEYmxhcFU/view?usp=sharing
 [2016-04-22 08:18 UTC] tony2001@php.net
-Assigned To: tony2001 +Assigned To: cataphract
 [2016-04-22 08:18 UTC] tony2001@php.net
Gustavo, can you take a look at it?
 [2017-07-17 14:21 UTC] cataphract@php.net
-Status: Assigned +Status: Feedback
 [2017-07-17 14:21 UTC] cataphract@php.net
I couldn't reproduce this with files I created myself and the link you sent no longer works. Can you upload it again, please?
 [2017-07-30 04:22 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 20:01:28 2024 UTC