From bdb81d0bd13eb39e1b31b19e5c25112a532b2ffb Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 27 Sep 2016 13:13:44 +0200 Subject: 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 --- src/corelib/io/qdiriterator.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/corelib/io') 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(); -- cgit v1.2.3