Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check temp path before deleting files in __destruct to avoid Object Injection #664

Open
wants to merge 2 commits into
base: 2
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
silverstripe requires PHP8 so we can use str_starts_with
  • Loading branch information
mcdruid committed Dec 4, 2024
commit 16006f5578cb6b5ba68a31021bac5b2c7d85eb1e
2 changes: 1 addition & 1 deletion src/InterventionBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ public function __destruct()
$this->image->destroy();
}
// remove our temp file if it exists
if ((strpos(basename($this->getTempPath()), 'interventionimage_') === 0) && file_exists($this->getTempPath() ?? '')) {
if (str_starts_with(basename($this->getTempPath()), 'interventionimage_') && file_exists($this->getTempPath() ?? '')) {
unlink($this->getTempPath() ?? '');
}
}
Expand Down