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>
bb10
Simon Hausmann 2016-09-27 13:13:44 +02:00 committed by Simon Hausmann
parent 3efb84ffdb
commit bdb81d0bd1
1 changed files with 1 additions and 0 deletions

View File

@ -254,6 +254,7 @@ void QDirIteratorPrivate::advance()
if (entryMatches(nextEntry.fileName(), info))
return;
nextMetaData = QFileSystemMetaData();
}
nativeIterators.pop();