summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qfile/tst_qfile.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-09-04 15:26:10 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-10-24 13:37:22 +0200
commit9ab043b6889739ce495c395281774ee2db706dab (patch)
treef22d28b1e3beb8013b31fb139f3d06eb7b740d19 /tests/auto/corelib/io/qfile/tst_qfile.cpp
parentf2edc6cb3a12063005c77aae7946f4a07d3bd30c (diff)
QFileSystemEngine: Consistently check for invalid file names
stat() and friends expect a null-terminated C string. There is no way to generate anything useful from a string that has null bytes in the middle. It's important to catch this early, as otherwise, for example, a QDir::exists() on such a path can return true, as the path is silently truncated. Extend the checks for empty file names to windows and add checks for null bytes. Change-Id: Ie9794c3a7c4fd57f9a66bdbbab8b45a08b6f9170 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/io/qfile/tst_qfile.cpp')
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index 4f010f37c2..b8ae95dd93 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -550,6 +550,10 @@ void tst_QFile::exists()
QFile unc(uncPath);
QVERIFY2(unc.exists(), msgFileDoesNotExist(uncPath).constData());
#endif
+
+ QTest::ignoreMessage(QtWarningMsg, "Broken filename passed to function");
+ QVERIFY(!QFile::exists(QDir::currentPath() + QLatin1Char('/') +
+ QChar(QChar::Null) + QLatin1String("x/y")));
}
void tst_QFile::open_data()