Skip to content

Commit

Permalink
don't run empty or unreadable storage file through unseralize, throw …
Browse files Browse the repository at this point in the history
…exception instead
  • Loading branch information
dannyvankooten committed Nov 30, 2023
1 parent 5d04808 commit da5ea09
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Rates.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ private function load(): void
private function loadFromFile(): void
{
$contents = file_get_contents($this->storagePath);
if ($contents === false || $contents === '') {
throw new Exception("Unserializable file content");
}

$data = unserialize($contents, [
'allowed_classes' => [
Period::class,
Expand Down

0 comments on commit da5ea09

Please sign in to comment.