Skip to content

Commit ba5549a

Browse files
authored
Merge pull request SimpleMachines#9076 from jdarwood007/3.0/writeableCheck
[3.0] Safety check on backup file
2 parents 0835d41 + 83264e9 commit ba5549a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sources/Config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2441,7 +2441,7 @@ public static function safeFileWrite(string $file, string $data, ?string $backup
24412441
// Tests passed, so it's time to do the job.
24422442
if (!$failed) {
24432443
// Back up the backup, just in case.
2444-
if (!empty($backup_file) && file_exists($backup_file)) {
2444+
if (!empty($backup_file) && file_exists($backup_file) && is_readable($backup_file)) {
24452445
$temp_bfile_saved = @copy($backup_file, $temp_bfile);
24462446
}
24472447

@@ -2483,7 +2483,7 @@ public static function safeFileWrite(string $file, string $data, ?string $backup
24832483
}
24842484
}
24852485
// It worked, so make our temp backup the new permanent backup.
2486-
elseif (!empty($backup_file)) {
2486+
elseif (!empty($backup_file) && file_exists($temp_sfile) && is_readable($backup_file) && is_writable($backup_file)) {
24872487
@rename($temp_sfile, $backup_file);
24882488
}
24892489

0 commit comments

Comments
 (0)