php.net |  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
Votes:1
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: vangog at gmail dot com
New email:
PHP Version: OS:

 

 [2014-02-28 15:18 UTC] vangog at gmail dot com
Description:
------------
1)
$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	=	'https://dl.dropboxusercontent.com/u/73282442/Twisted_Sister-A_Twisted_Christmas-2006-MP3.r00';
		$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();
		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_copy_to_stream($stream,$stream_fp);
			$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";
			unlink($path_extract);
			fclose($stream_fp);
			unlink($stream_path);
		}

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 

Patches

Pull Requests

History

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] cataphract@php.net
-Status: Open +Status: Duplicate
 [2020-10-11 18:21 UTC] cataphract@php.net
Should be fixed in 4.1.0.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Apr 28 03:01:28 2025 UTC