Commit 4027cab3 authored by webchick's avatar webchick
Browse files

Issue #2240023 by beejeebus: Make sure we use a unique temp filename for php storage.

parent 562addaf
...@@ -70,8 +70,8 @@ public function save($name, $data) { ...@@ -70,8 +70,8 @@ public function save($name, $data) {
// Write the file out to a temporary location. Prepend with a '.' to keep it // Write the file out to a temporary location. Prepend with a '.' to keep it
// hidden from listings and web servers. // hidden from listings and web servers.
$temporary_path = $this->directory . '/.' . str_replace('/', '#', $name); $temporary_path = tempnam($this->directory, '.');
if (!@file_put_contents($temporary_path, $data)) { if (!$temporary_path || !@file_put_contents($temporary_path, $data)) {
return FALSE; return FALSE;
} }
// The file will not be chmod() in the future so this is the final // The file will not be chmod() in the future so this is the final
...@@ -102,6 +102,8 @@ public function save($name, $data) { ...@@ -102,6 +102,8 @@ public function save($name, $data) {
// Reset the file back in the temporary location if this is not the first // Reset the file back in the temporary location if this is not the first
// iteration. // iteration.
if ($i > 0) { if ($i > 0) {
$this->unlink($temporary_path);
$temporary_path = tempnam($this->directory, '.');
rename($full_path, $temporary_path); rename($full_path, $temporary_path);
// Make sure to not loop infinitely on a hopelessly slow filesystem. // Make sure to not loop infinitely on a hopelessly slow filesystem.
if ($i > 10) { if ($i > 10) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment