summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qsavefile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io/qsavefile.cpp')
-rw-r--r--src/corelib/io/qsavefile.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/corelib/io/qsavefile.cpp b/src/corelib/io/qsavefile.cpp
index 0283c5f31f..3f45ca5f91 100644
--- a/src/corelib/io/qsavefile.cpp
+++ b/src/corelib/io/qsavefile.cpp
@@ -232,7 +232,11 @@ bool QSaveFile::open(OpenMode mode)
}
d->fileEngine = new QTemporaryFileEngine;
- static_cast<QTemporaryFileEngine *>(d->fileEngine)->initialize(d->finalFileName, 0666);
+ // if the target file exists, we'll copy its permissions below,
+ // but until then, let's ensure the temporary file is not accessible
+ // to a third party
+ int perm = (existingFile.exists() ? 0600 : 0666);
+ static_cast<QTemporaryFileEngine *>(d->fileEngine)->initialize(d->finalFileName, perm);
// Same as in QFile: QIODevice provides the buffering, so there's no need to request it from the file engine.
if (!d->fileEngine->open(mode | QIODevice::Unbuffered)) {
QFileDevice::FileError err = d->fileEngine->error();