Skip to content

Commit

Permalink
Fix a bug where logs over 2 GB would be skipped.
Browse files Browse the repository at this point in the history
On 32-bit systems, SplFileInfo::getSize() can return a negative integer when the file size exceeds 2 GB. This means that checking for empty files by asking if getSize() < 1 isn't reliable. Lets explicitly compare it to zero instead.

Possible risks:
A commenter on php.net claims that getSize() can return false if the file doesn't exist (documentation claims otherwise). We should never encounter that situation because we already check if the file specified as the --log argument exists, and we can (probably?) assume that iterating through the directory specified as the --dir argument will not return non-existent files.
  • Loading branch information
YahnisElsts committed Jun 10, 2017
1 parent 1c7921e commit b0f19fd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/MultiFileReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct($files) {
$object = new \SplFileObject($fileName);

//Skip empty files.
if ($object->getSize() < 1) {
if ($object->getSize() === 0) {
continue;
}

Expand Down

0 comments on commit b0f19fd

Please sign in to comment.