Skip to content

Commit b9d1f53

Browse files
authored
Don't stop reading if fread returns an empty string (#20)
This fixes a premature loop termination on empty string read, which can happen when reading from network streams, leading to packing truncated files silently. By explicitly checking against "false", the loop will terminate only if fread returns a failure.
1 parent b04e520 commit b9d1f53

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/ZipStreamer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ private function streamFileData($stream, $compress, $level) {
356356
$compStream = DeflateStream::create($level);
357357
}
358358

359-
while (!feof($stream) && $data = fread($stream, self::STREAM_CHUNK_SIZE)) {
359+
while (!feof($stream) && ($data = fread($stream, self::STREAM_CHUNK_SIZE)) !== false) {
360360
$dataLength->add(strlen($data));
361361
hash_update($hashCtx, $data);
362362
if (COMPR::DEFLATE === $compress) {

0 commit comments

Comments
 (0)