diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-03-14 10:37:39 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-03-16 06:40:09 +0000 |
commit | 6f34c0e13feb60b21a8702f7fdc24afdb4ce3922 (patch) | |
tree | ef6b06ce606b46728ebe5e38d654551259bbc25f | |
parent | fdef544f66043206169fd8ef2b38781936106b0b (diff) |
QFileSystemEngine: fix potential formatting error
It's not immediately clear that trashedName doesn't contain %1 or %2,
in which case the subsequent .arg() would replace that instead of the
intended %2.
Fix by using QString::asprintf(), which doesn't perform multiple
interpolation passes.
Change-Id: Ib6c24bfea01db4cdc80f7547c8269cce3f815158
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
(cherry picked from commit bbae5c891b8807399271a655f99a3c90882a0f9e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/corelib/io/qfilesystemengine_unix.cpp | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 108f212334..efb42fa715 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -1367,10 +1367,7 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source, int counter = 0; QFile infoFile; auto makeUniqueTrashedName = [trashedName, &counter]() -> QString { - ++counter; - return QString(QLatin1String("/%1-%2")) - .arg(trashedName) - .arg(counter, 4, 10, QLatin1Char('0')); + return QString::asprintf("/%ls-%04d", qUtf16Printable(trashedName), ++counter); }; do { while (QFile::exists(trashDir.filePath(filesDir) + uniqueTrashedName)) |