summaryrefslogtreecommitdiffstats
path: root/netwerk
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-07-10 18:16:22 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-07-10 18:16:22 +0200
commitdaf0b30772427f5faefe11d724b63c39d2f97b7d (patch)
tree340369cee60c36af70724080ffec7172054f9ff8 /netwerk
parent4483ac5c5f082e4efb21ab711aec9a0a74d20448 (diff)
downloadUXP-daf0b30772427f5faefe11d724b63c39d2f97b7d.tar
UXP-daf0b30772427f5faefe11d724b63c39d2f97b7d.tar.gz
UXP-daf0b30772427f5faefe11d724b63c39d2f97b7d.tar.lz
UXP-daf0b30772427f5faefe11d724b63c39d2f97b7d.tar.xz
UXP-daf0b30772427f5faefe11d724b63c39d2f97b7d.zip
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.
Diffstat (limited to 'netwerk')
-rw-r--r--netwerk/base/nsFileStreams.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/netwerk/base/nsFileStreams.cpp b/netwerk/base/nsFileStreams.cpp
index 2ddb7ae98..6508b33b9 100644
--- a/netwerk/base/nsFileStreams.cpp
+++ b/netwerk/base/nsFileStreams.cpp
@@ -1015,11 +1015,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);