From ee0a1e1b41209730b478babad8e7c5f3010f4fe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sun, 29 Nov 2020 01:08:43 +0000 Subject: [PATCH] Add a limit on the amount of data that can be passed back via DBus. --- src/util/externalcommandhelper.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/util/externalcommandhelper.cpp b/src/util/externalcommandhelper.cpp index e485986..cbfa76e 100644 --- a/src/util/externalcommandhelper.cpp +++ b/src/util/externalcommandhelper.cpp @@ -163,10 +163,15 @@ QVariantMap ExternalCommandHelper::CopyBlocks(const QString& sourceDevice, const if (!blockSize) { return QVariantMap(); } + + // Prevent some out of memory situations constexpr qint64 MiB = 1 << 30; if (blockSize > 100 * MiB) { return QVariantMap(); } + if (targetDevice.isEmpty() && sourceLength > MiB) { + return QVariantMap(); + } QVariantMap reply; reply[QStringLiteral("success")] = true;