[X2Go-Commits] [pale-moon] 19/22: Make nsAtomicFileOutputStream::DoOpen() fail if the file is read-only.
git-admin at x2go.org
git-admin at x2go.org
Sat Sep 29 03:25:24 CEST 2018
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch upstream/palemoon-master
in repository pale-moon.
commit 9ced226336e2ef5c88be3179519d19fcdf8b0aee
Author: Pale Moon <git-repo at palemoon.org>
Date: Tue Jul 10 17:51:04 2018 +0200
Make nsAtomicFileOutputStream::DoOpen() fail if the file is read-only.
This means we don't leave behind prefs-<n>.js files when prefs.js is read-only.
---
netwerk/base/nsFileStreams.cpp | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/netwerk/base/nsFileStreams.cpp b/netwerk/base/nsFileStreams.cpp
index 8b719df..1946fc7 100644
--- a/netwerk/base/nsFileStreams.cpp
+++ b/netwerk/base/nsFileStreams.cpp
@@ -907,11 +907,18 @@ nsAtomicFileOutputStream::DoOpen()
}
if (NS_SUCCEEDED(rv) && mTargetFileExists) {
+ // Abort if |file| is not writable; it won't work as an output stream.
+ bool isWritable;
+ if (NS_SUCCEEDED(file->IsWritable(&isWritable)) && !isWritable) {
+ return NS_ERROR_FILE_ACCESS_DENIED;
+ }
+
uint32_t origPerm;
if (NS_FAILED(file->GetPermissions(&origPerm))) {
NS_ERROR("Can't get permissions of target file");
origPerm = mOpenParams.perm;
}
+
// XXX What if |perm| is more restrictive then |origPerm|?
// This leaves the user supplied permissions as they were.
rv = tempResult->CreateUnique(nsIFile::NORMAL_FILE_TYPE, origPerm);
--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/pale-moon.git
More information about the x2go-commits
mailing list