diff options
Diffstat (limited to 'src/corelib/io/qfsfileengine_win.cpp')
-rw-r--r-- | src/corelib/io/qfsfileengine_win.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index e427b62136..7d16e59195 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -108,6 +108,20 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode) { Q_Q(QFSFileEngine); + // Check if the file name is valid: + // https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#naming_conventions + const QString fileName = fileEntry.fileName(); + for (QString::const_iterator it = fileName.constBegin(), end = fileName.constEnd(); + it != end; ++it) { + const QChar c = *it; + if (c == QLatin1Char('<') || c == QLatin1Char('>') || c == QLatin1Char(':') || + c == QLatin1Char('\"') || c == QLatin1Char('/') || c == QLatin1Char('\\') || + c == QLatin1Char('|') || c == QLatin1Char('?') || c == QLatin1Char('*')) { + q->setError(QFile::OpenError, QStringLiteral("Invalid file name")); + return false; + } + } + // All files are opened in share mode (both read and write). DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; @@ -850,7 +864,6 @@ QDateTime QFSFileEngine::fileTime(FileTime time) const uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFlags flags) { -#ifndef Q_OS_WINPHONE Q_Q(QFSFileEngine); Q_UNUSED(flags); if (openMode == QFile::NotOpen) { @@ -960,18 +973,11 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, ::CloseHandle(mapHandle); mapHandle = NULL; -#else // !Q_OS_WINPHONE - Q_UNUSED(offset); - Q_UNUSED(size); - Q_UNUSED(flags); - Q_UNIMPLEMENTED(); -#endif // Q_OS_WINPHONE return 0; } bool QFSFileEnginePrivate::unmap(uchar *ptr) { -#ifndef Q_OS_WINPHONE Q_Q(QFSFileEngine); if (!maps.contains(ptr)) { q->setError(QFile::PermissionsError, qt_error_string(ERROR_ACCESS_DENIED)); @@ -990,11 +996,6 @@ bool QFSFileEnginePrivate::unmap(uchar *ptr) } return true; -#else // !Q_OS_WINPHONE - Q_UNUSED(ptr); - Q_UNIMPLEMENTED(); - return false; -#endif // Q_OS_WINPHONE } QT_END_NAMESPACE |