Skip to content

Commit 610ccff

Browse files
[Filesystem] Strengthen the check of file permissions in dumpFile
1 parent 50268e6 commit 610ccff

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,8 @@ 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+
$perms = fileperms($filename);
695+
self::box('chmod', $tmpFile, file_exists($filename) && false !== $perms ? $perms : 0666 & ~umask());
695696

696697
$this->rename($tmpFile, $filename, true);
697698
} finally {

src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTestCase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ public function testGuessWithNonReadablePath()
116116
touch($path);
117117
@chmod($path, 0333);
118118

119-
if (str_ends_with(sprintf('%o', fileperms($path)), '0333')) {
119+
$perms = fileperms($path);
120+
if (false !== $perms && str_ends_with(sprintf('%o', $perms), '0333')) {
120121
$this->expectException(\InvalidArgumentException::class);
121122
$this->getGuesser()->guessMimeType($path);
122123
} else {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy