mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-15 08:53:07 +09:00
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.
This commit is contained in:
parent
9453a7812a
commit
5ffd703f79
1 changed files with 7 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue