From c70658d301e274c3aaa1fb6cebe2a5e56db12779 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 16 Dec 2014 14:24:55 -0800 Subject: Make sure we don't try to ask QByteArray to allocate too much QFile::readAll could be asked to read a file that is over 1 GB in size and thus cause an assertion: ASSERT failure in qAllocMore: "Requested size is too large!", ... The idea behind the existing code was correct, but the value was wrong. It prevented overflow of the integer size request, but didn't prevent overflowing the storage size. Change-Id: I072e6e419f47b639454f3fd96deb0f88d03e960c Reviewed-by: Martin Smith --- src/corelib/io/qiodevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 0709a93bad..72ec6ff403 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -1025,7 +1025,7 @@ QByteArray QIODevice::readAll() } else { // Read it all in one go. // If resize fails, don't read anything. - if (readBytes + theSize - d->pos > INT_MAX) + if (quint64(readBytes + theSize - d->pos) > QByteArray::MaxSize) return QByteArray(); result.resize(int(readBytes + theSize - d->pos)); readBytes += read(result.data() + readBytes, result.size() - readBytes); -- cgit v1.2.3 From 13972476ad2c3178fe89f2d96f398de10394c6f6 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Mon, 22 Dec 2014 13:44:45 +0300 Subject: qstorageinfo_unix.cpp: Fix build on BSD and other unices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Include statvfs.h on all non-Linux and non-Solaris systems. * Fix type of stat_buf structure on BSD. Change-Id: I6336503082fafd7f6108cf95c079bdd329d2ea0f Reviewed-by: Gabriel de Dietrich Reviewed-by: Lisandro Damián Nicanor Pérez Meyer Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Shawn Rutledge --- src/corelib/io/qstorageinfo_unix.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index e82737c51c..857464f578 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -52,17 +52,18 @@ #if defined(Q_OS_BSD4) # include +# include #elif defined(Q_OS_ANDROID) # include # include # include -#elif defined(Q_OS_QNX) -# include #elif defined(Q_OS_LINUX) # include # include #elif defined(Q_OS_SOLARIS) # include +#else +# include #endif #if defined(Q_OS_BSD4) @@ -118,7 +119,7 @@ public: inline QByteArray device() const; private: #if defined(Q_OS_BSD4) - statfs *stat_buf; + struct statfs *stat_buf; int entryCount; int currentIndex; #elif defined(Q_OS_SOLARIS) -- cgit v1.2.3