Compare commits

...

6 Commits

3 changed files with 26 additions and 11 deletions

View File

@ -9,8 +9,8 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
# KDE Application Version, managed by release script
set (RELEASE_SERVICE_VERSION_MAJOR "20")
set (RELEASE_SERVICE_VERSION_MINOR "11")
set (RELEASE_SERVICE_VERSION_MICRO "80")
set (RELEASE_SERVICE_VERSION_MINOR "12")
set (RELEASE_SERVICE_VERSION_MICRO "0")
set (RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_VERSION_MINOR}.${RELEASE_SERVICE_VERSION_MICRO}")
project(kpmcore VERSION ${RELEASE_SERVICE_VERSION})

View File

@ -158,6 +158,21 @@ QVariantMap ExternalCommandHelper::CopyBlocks(const QString& sourceDevice, const
if (!isCallerAuthorized()) {
return QVariantMap();
}
// Avoid division by zero further down
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;
@ -279,15 +294,16 @@ QVariantMap ExternalCommandHelper::RunCommand(const QString& command, const QStr
// connect(&cmd, &QProcess::readyReadStandardOutput, this, &ExternalCommandHelper::onReadOutput);
m_cmd.setEnvironment( { QStringLiteral("LVM_SUPPRESS_FD_WARNINGS=1") } );
m_cmd.setProcessChannelMode(static_cast<QProcess::ProcessChannelMode>(processChannelMode));
m_cmd.start(command, arguments);
m_cmd.write(input);
m_cmd.closeWriteChannel();
m_cmd.waitForFinished(-1);
QByteArray output = m_cmd.readAllStandardOutput();
QProcess cmd;
cmd.setEnvironment( { QStringLiteral("LVM_SUPPRESS_FD_WARNINGS=1") } );
cmd.setProcessChannelMode(static_cast<QProcess::ProcessChannelMode>(processChannelMode));
cmd.start(command, arguments);
cmd.write(input);
cmd.closeWriteChannel();
cmd.waitForFinished(-1);
QByteArray output = cmd.readAllStandardOutput();
reply[QStringLiteral("output")] = output;
reply[QStringLiteral("exitCode")] = m_cmd.exitCode();
reply[QStringLiteral("exitCode")] = cmd.exitCode();
return reply;
}

View File

@ -46,7 +46,6 @@ private:
bool isCallerAuthorized();
void onReadOutput();
QProcess m_cmd;
QDBusServiceWatcher *m_serviceWatcher = nullptr;
};