Commit 4ef17463 authored by Andrius Štikonas's avatar Andrius Štikonas
Browse files

Make sure that path passed to WriteData is block device.

parent 81a5eae6
Pipeline #133454 passed with stage
in 3 minutes and 17 seconds
......@@ -291,7 +291,7 @@ QByteArray ExternalCommandHelper::ReadData(const QString& device, const qint64 o
if (length > MiB) {
return {};
}
if (!std::filesystem::is_block_file(device.toStdString())) {
if (!std::filesystem::is_block_file(device.toStdU16String())) {
qWarning() << "Not a block device";
return {};
}
......@@ -313,7 +313,15 @@ bool ExternalCommandHelper::WriteData(const QByteArray& buffer, const QString& t
if ( targetDevice.left(5) != QStringLiteral("/dev/") )
return false;
return writeData(targetDevice, buffer, targetOffset);
auto targetPath = std::filesystem::path(targetDevice.toStdU16String());
if (!std::filesystem::is_block_file(targetDevice.toStdU16String())) {
qWarning() << "Not a block device";
return {};
}
auto canonicalTargetPath = std::filesystem::canonical(targetPath);
return writeData(QLatin1String(canonicalTargetPath.c_str()), buffer, targetOffset);
}
QVariantMap ExternalCommandHelper::RunCommand(const QString& command, const QStringList& arguments, const QByteArray& input, const int processChannelMode)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment