8000 bug #54471 [Filesystem] Strengthen the check of file permissions in `… · symfony/symfony@e483eee · GitHub
[go: up one dir, main page]

Skip to content

Commit e483eee

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 ------- 0c17a4e [Filesystem] Strengthen the check of file permissions in `dumpFile`
2 parents e9a7cb9 + 0c17a4e commit e483eee

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/Filesystem/Filesystem.php

+1-1
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)
0