Skip to content

Commit db9c7b1

Browse files
bug #54471 [Filesystem] Strengthen the check of file permissions in dumpFile (alexandre-daubois)
This PR was merged into the 5.4 branch. Discussion ---------- [Filesystem] Strengthen the check of file permissions in `dumpFile` | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #54444 | License | MIT `fileperms()` can fail and return `false`, I think we should strengthen the checks on its return value when using it to avoid undesirable behavior. Commits ------- 0c17a4e327 [Filesystem] Strengthen the check of file permissions in `dumpFile`
2 parents 4303603 + 6dc5233 commit db9c7b1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Filesystem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ public function dumpFile(string $filename, $content)
691691
throw new IOException(sprintf('Failed to write file "%s": ', $filename).self::$lastError, 0, null, $filename);
692692
}
693693

694-
self::box('chmod', $tmpFile, file_exists($filename) ? fileperms($filename) : 0666 & ~umask());
694+
self::box('chmod', $tmpFile, @fileperms($filename) ?: 0666 & ~umask());
695695

696696
$this->rename($tmpFile, $filename, true);
697697
} finally {

0 commit comments

Comments
 (0)