summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qiodevice.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2014-09-19 14:17:46 -0700
committerThiago Macieira <thiago.macieira@intel.com>2014-10-31 03:56:11 +0100
commit85da1625e47cadf0b41e24863e8988e771e50943 (patch)
tree892b2a86a0951e4521c6c3fd4a311005d0baf127 /src/corelib/io/qiodevice.cpp
parentf91b81ca398c64a22fd6fb2006dbec39a3e3b2c0 (diff)
Attempt to make QFile I/O 64-bit safe
Use qint64 wherever possible. The linear buffer is never requested to allocate that much memory (always limited), but at least we ensure we're not dropping bits where we shouldn't. Windows's POSIX compatibility layer is never largefile enabled, so it is always necessary to chunk large reads and writes. On Unix, this will be rare, unless someone passed -no-largefile to configure, for some weird reason. Unfortunately, this is not testable, unless we can allocate a buffer with 4 GB or more in size. The test for this would be to open a file we know to be small, then try to read 4 GB + 1 byte. If everything works correctly, we'll read the full file; if there was a truncation, we'd read one byte. Change-Id: If3ee511bf1de17e0123c85bbcaa463b9972746ce Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qiodevice.cpp')
-rw-r--r--src/corelib/io/qiodevice.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index 89209e6118..0709a93bad 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -786,7 +786,7 @@ qint64 QIODevice::read(char *data, qint64 maxSize)
bool moreToRead = true;
do {
// Try reading from the buffer.
- int lastReadChunkSize = d->buffer.read(data, maxSize);
+ qint64 lastReadChunkSize = d->buffer.read(data, maxSize);
if (lastReadChunkSize > 0) {
*d->pPos += lastReadChunkSize;
readSoFar += lastReadChunkSize;