Skip to content

Commit ed2fd8b

Browse files
committed
simplify EOCD-not-found check
Drop the $found flag: after the loop, $bytes can only equal the EOCD signature if we broke out, since the check runs on every iteration.
1 parent 151c93d commit ed2fd8b

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

src/Zip.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,19 +554,17 @@ protected function readCentralDir()
554554
@fseek($this->fh, $size - $maximum_size);
555555
$pos = ftell($this->fh);
556556
$bytes = 0x00000000;
557-
$found = false;
558557

559558
while ($pos < $size) {
560559
$byte = @fread($this->fh, 1);
561560
$bytes = (($bytes << 8) & 0xFFFFFFFF) | ord($byte);
562561
if ($bytes == 0x504b0506) {
563-
$found = true;
564562
break;
565563
}
566564
$pos++;
567565
}
568566

569-
if (!$found) {
567+
if ($bytes != 0x504b0506) {
570568
throw new ArchiveCorruptedException(
571569
'End of central directory signature not found - not a valid ZIP file'
572570
);

0 commit comments

Comments
 (0)