summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2016-09-27 13:13:44 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2016-09-27 15:45:04 +0000
commitbdb81d0bd13eb39e1b31b19e5c25112a532b2ffb (patch)
tree6885ee9d78a43e30f4c15faa1f0147f1cd4930f9
parent3efb84ffdbcfbd9969b765b7cffd01da231e7ba6 (diff)
Avoid re-use of QFileSystemMetaData instance in dir entry listing
We've observed that on machines with SELinux installed but disabled, the behavior of readdir() changes slightly. In the case of tst_qdir's entryList QDir::Hidden test case, the listing of the directory contents returns DT_UNKNOWN for the files and (broken) symlink(s) that are present. When SELinux is enabled, we do see DT_REG and DT_LNK. Our fallback to DT_UNKNOWN however resets merely the knownFlags, it does not reset entryFlags, as all the other cases do. The bug comes when QDirIteratorPrivate::advance() re-uses the QFileSystemMetaData instance across iterations, and this way we get the entryFlags values from a previous iteration (with != DT_UNKNOWN) into the evaluation of an entry with DT_UNKNOWN. The more conservative approach to fixing this is here by assuming that QFileSystemMetaData is not designed for re-use and re-initialize it explicitly in the iteration. Change-Id: I875856f5ee63a7072d172033e90d02cf41bcab20 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
-rw-r--r--src/corelib/io/qdiriterator.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp
index a6394c16cc..5fd9edc552 100644
--- a/src/corelib/io/qdiriterator.cpp
+++ b/src/corelib/io/qdiriterator.cpp
@@ -254,6 +254,7 @@ void QDirIteratorPrivate::advance()
if (entryMatches(nextEntry.fileName(), info))
return;
+ nextMetaData = QFileSystemMetaData();
}
nativeIterators.pop();