summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorØystein Heskestad <oystein.heskestad@qt.io>2021-03-03 12:23:18 +0100
committerQt CI Bot <qt_ci_bot@qt-project.org>2021-03-05 16:32:49 +0000
commitde658d8ca539d6b2ce1b47e7bd8f71e25b2a63d7 (patch)
tree1601e0134031794066ce86518d18752e7401de95 /src/network
parent89e9164abbd730e4f3db7e56ece3477199fbeaa9 (diff)
parentbe73ca7eb1cebcc15064666e647bc337b5c2baa2 (diff)
Merge "Make qdecompresshelper archive bomb check only trigger for large files"
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qdecompresshelper.cpp8
-rw-r--r--src/network/access/qdecompresshelper_p.h2
2 files changed, 10 insertions, 0 deletions
diff --git a/src/network/access/qdecompresshelper.cpp b/src/network/access/qdecompresshelper.cpp
index 2e44a58cf4..d0e75ef0dc 100644
--- a/src/network/access/qdecompresshelper.cpp
+++ b/src/network/access/qdecompresshelper.cpp
@@ -405,6 +405,11 @@ void QDecompressHelper::setArchiveBombDetectionEnabled(bool enable)
countHelper->setArchiveBombDetectionEnabled(enable);
}
+void QDecompressHelper::setMinimumArchiveBombSize(qint64 threshold)
+{
+ minimumArchiveBombSize = threshold;
+}
+
bool QDecompressHelper::isPotentialArchiveBomb() const
{
if (!archiveBombDetectionEnabled)
@@ -413,6 +418,9 @@ bool QDecompressHelper::isPotentialArchiveBomb() const
if (totalCompressedBytes == 0)
return false;
+ if (totalUncompressedBytes <= minimumArchiveBombSize)
+ return false;
+
// Some protection against malicious or corrupted compressed files that expand far more than
// is reasonable.
double ratio = double(totalUncompressedBytes) / double(totalCompressedBytes);
diff --git a/src/network/access/qdecompresshelper_p.h b/src/network/access/qdecompresshelper_p.h
index 4e66581022..6a77775790 100644
--- a/src/network/access/qdecompresshelper_p.h
+++ b/src/network/access/qdecompresshelper_p.h
@@ -92,6 +92,7 @@ public:
void clear();
void setArchiveBombDetectionEnabled(bool enable);
+ void setMinimumArchiveBombSize(qint64 threshold);
static bool isSupportedEncoding(const QByteArray &encoding);
static QByteArrayList acceptedEncoding();
@@ -119,6 +120,7 @@ private:
// Used for calculating the ratio
bool archiveBombDetectionEnabled = true;
+ qint64 minimumArchiveBombSize = 10 * 1024 * 1024;
qint64 totalUncompressedBytes = 0;
qint64 totalCompressedBytes = 0;