summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfsfileengine_win.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-08-26 13:03:59 +0200
committerLars Knoll <lars.knoll@digia.com>2014-08-29 09:32:30 +0200
commit1d66c9eba81ea8b73f354984e9eca2beda089faf (patch)
tree9ee6c9748b0a879f5b148f0da0dc3e9f9ce38761 /src/corelib/io/qfsfileengine_win.cpp
parentfc4993be1fa7673016b6e5d81134463f163051f6 (diff)
Fix nativeRead() for maxlen greater than UINT_MAX
Don't truncate the maxlen to a DWORD. Instead read all data incrementally up t maxlen. Task-number: QTBUG-27796 Change-Id: I21c34d11046f1106244dcd77420cc472e7240e68 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qfsfileengine_win.cpp')
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index 81aed5f7b4..cebca1a56f 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -369,15 +369,15 @@ qint64 QFSFileEnginePrivate::nativeRead(char *data, qint64 maxlen)
if (fileHandle == INVALID_HANDLE_VALUE)
return -1;
- DWORD bytesToRead = DWORD(maxlen); // <- lossy
+ qint64 bytesToRead = maxlen;
// Reading on Windows fails with ERROR_NO_SYSTEM_RESOURCES when
// the chunks are too large, so we limit the block size to 32MB.
- static const DWORD maxBlockSize = 32 * 1024 * 1024;
+ static const qint64 maxBlockSize = 32 * 1024 * 1024;
qint64 totalRead = 0;
do {
- DWORD blockSize = qMin<DWORD>(bytesToRead, maxBlockSize);
+ DWORD blockSize = DWORD(qMin(bytesToRead, maxBlockSize));
DWORD bytesRead;
if (!ReadFile(fileHandle, data + totalRead, blockSize, &bytesRead, NULL)) {
if (totalRead == 0) {
@@ -392,7 +392,7 @@ qint64 QFSFileEnginePrivate::nativeRead(char *data, qint64 maxlen)
totalRead += bytesRead;
bytesToRead -= bytesRead;
} while (totalRead < maxlen);
- return qint64(totalRead);
+ return totalRead;
}
/*