summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qiodevice.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-08-26 13:07:05 +0200
committerLars Knoll <lars.knoll@digia.com>2014-09-15 08:08:42 +0200
commit0c748fb7b109244c03eebbceb400db53af95974c (patch)
tree3e9ac5ce8b960cfb7dece23c52aaec1c74938b29 /src/corelib/io/qiodevice.cpp
parent0f92875891efca16599d7fd4f29b3f397cd2ca4e (diff)
Fix 64 bit issues in QIODevicePrivateLinearBuffer
The API was using int, not qint64 leading to implicit truncation of numbers in a few places Task-number: QTBUG-40974 Change-Id: I13aedc84557a19b6f74fe6825764e7b5827f27b0 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
Diffstat (limited to 'src/corelib/io/qiodevice.cpp')
-rw-r--r--src/corelib/io/qiodevice.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index 53019e1ff4..51a574987e 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -833,7 +833,7 @@ qint64 QIODevice::read(char *data, qint64 maxSize)
// In buffered mode, we try to fill up the QIODevice buffer before
// we do anything else.
// buffer is empty at this point, try to fill it
- int bytesToBuffer = QIODEVICE_BUFFERSIZE;
+ const int bytesToBuffer = QIODEVICE_BUFFERSIZE;
char *writePointer = d->buffer.reserve(bytesToBuffer);
// Make sure the device is positioned correctly.
@@ -1013,6 +1013,8 @@ QByteArray QIODevice::readAll()
// flush internal read buffer
if (!(d->openMode & Text) && !d->buffer.isEmpty()) {
+ if (d->buffer.size() >= INT_MAX)
+ return QByteArray();
result = d->buffer.readAll();
readBytes = result.size();
d->pos += readBytes;
@@ -1031,6 +1033,8 @@ QByteArray QIODevice::readAll()
} else {
// Read it all in one go.
// If resize fails, don't read anything.
+ if (readBytes + theSize - d->pos > INT_MAX)
+ return QByteArray();
result.resize(int(readBytes + theSize - d->pos));
readBytes += read(result.data() + readBytes, result.size() - readBytes);
}