|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesFix-incorrect-buffer_size-calculation-with-streams (last revision 2018-07-06 23:58 UTC by magrodriguez93 at gmail dot com)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-07-07 00:06 UTC] magrodriguez93 at gmail dot com
[2020-10-11 18:20 UTC] cataphract@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: cataphract
[2020-10-11 18:20 UTC] cataphract@php.net
[2020-10-11 18:20 UTC] cataphract@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 23:00:01 2025 UTC |
Description: ------------ Whenever the unpacked size of a file is greater than RAR_CHUNK_BUFFER_SIZE only RAR_CHUNK_BUFFER_SIZE bytes are allocated for the stream, resulting in incomplete reads. Generate a random 10MB file and add it to a RAR archive. dd if=/dev/urandom of=test.dat bs=1M count=10 && rar a test.rar test.dat Test script: --------------- $rar = \RarArchive::open('test.rar'); if ($rar === false) die('Unable to open archive.'); $entry = $rar->getEntry('test.dat'); if ($entry === false) die('Unable to get entry.'); $contents = stream_get_contents($entry->getStream(), $entry->getUnpackedSize()); $expectedCRC = $entry->getCrc(); $actualCRC = dechex(crc32($contents)); if ($expectedCRC !== $actualCRC) die('CRC values do not match.'); die('All ok.'); Expected result: ---------------- The CRC values should match. Actual result: -------------- The CRC values do not match whenever the unpacked size is greater than RAR_CHUNK_BUFFER_SIZE.