summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qbytearray.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-09-06 21:36:48 +0200
committerThiago Macieira <thiago.macieira@intel.com>2022-09-11 13:55:01 +0000
commitf3512ada092111a787d5d067551451fc91b8491d (patch)
tree20dd429ad5fa5a4b096f941447e0694a1557dc71 /src/corelib/text/qbytearray.cpp
parent6ed89be125b2870394d8c6398f3a87ab9a1459b9 (diff)
qUncompress: limit MaxDecompressedSize to what zlib can handle
... which may be less than what QByteArray can handle, e.g. on Windows, where long, used in the zlib API as the size type, is just 32-bit. Re-define MaxDecompressedSize as the minimum of the maximum sizes supported by each of QByteArray and zlib, so we respect each library's individual limit. Pick-to: 6.4 6.3 6.2 Task-number: QTBUG-104972 Change-Id: If1894ae7a1888f651a82b153d463658c272287e3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/text/qbytearray.cpp')
-rw-r--r--src/corelib/text/qbytearray.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp
index 8d552b7fd0..6e65b06f65 100644
--- a/src/corelib/text/qbytearray.cpp
+++ b/src/corelib/text/qbytearray.cpp
@@ -632,7 +632,8 @@ QByteArray qUncompress(const uchar* data, qsizetype nbytes)
size_t expectedSize = size_t((data[0] << 24) | (data[1] << 16) |
(data[2] << 8) | (data[3] ));
size_t len = qMax(expectedSize, 1ul);
- constexpr size_t MaxDecompressedSize = size_t(MaxByteArraySize);
+ constexpr size_t MaxZLibSize = (std::numeric_limits<uLong>::max)();
+ constexpr size_t MaxDecompressedSize = (std::min)(size_t(MaxByteArraySize), MaxZLibSize);
if (len > MaxDecompressedSize)
return invalidCompressedData();