|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66796 $entry->getStream() returns incomplete data
Submitted: 2014-02-28 15:18 UTC Modified: 2020-10-11 18:21 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: vangog at gmail dot com Assigned:
Status: Duplicate Package: rar (PECL)
PHP Version: 5.4.25 OS: Linux
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: vangog at gmail dot com
New email:
PHP Version: OS:


 [2014-02-28 15:18 UTC] vangog at gmail dot com
$entry->getStream() returns incomplete data
or return unexpected EOF (guess)
but $entry->extract(false, $path_extract); extract valid file
Affected rar archive included in reproduce script

2) Why you package can not open remote (http) file. If remote server support HHTP_RANGE you can perform seek operations. Now a time of distributed storage :) 

Test script:
$remote_path	=	'';
		$local_path		=	sys_get_temp_dir().DIRECTORY_SEPARATOR.'buggy.rar';

		$rar = RarArchive::open($local_path);
		$entries = $rar->getEntries();
		foreach ($entries as $entry){
			$name			=	$entry->getName();
			$declared_size	=	$entry->getUnpackedSize();
			$declared_crc	=	$entry->getCrc();
			// Copy data from a stream
			$stream			=	$entry->getStream();
			$stream_path	=	sys_get_temp_dir().DIRECTORY_SEPARATOR.'stream';
			$stream_fp		=	fopen($stream_path,'w');
			$stream_size	=	filesize($stream_path);
			// extract file 
			$path_extract	=	sys_get_temp_dir().DIRECTORY_SEPARATOR.'extracted';
			$entry->extract(false, $path_extract); 
			$extract_size	=	filesize($path_extract);
			echo $name." \t Declared:".$declared_size." \t Stream:".$stream_size." Extracted:".$extract_size."\n";

Expected result:
03-twisted_sister-white_christmas.mp3 Declared:6705696 Stream:6705696 Extracted:6705696 

Actual result:
03-twisted_sister-white_christmas.mp3 Declared:6705696 Stream:4194304 Extracted:6705696 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-02-28 15:21 UTC] vangog at gmail dot com
-Summary: 3.0.0 - 3.0.2 +Summary: $entry->getStream() returns incomplete data
 [2014-02-28 15:21 UTC] vangog at gmail dot com
Test on versions 3.0.0 - 3.0.2
 [2014-02-28 15:23 UTC] vangog at gmail dot com
This not single rar I've notice the same behavior, can provide others examples, if it helps
 [2020-10-11 18:21 UTC]
-Status: Open +Status: Duplicate
 [2020-10-11 18:21 UTC]
Should be fixed in 4.1.0.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 01:01:33 2024 UTC