Commit 7320f942 authored by Andrius Štikonas's avatar Andrius Štikonas
Browse files

Open files in ReadData with O_NOFOLLOW.

parent 83a86541
Pipeline #195639 passed with stage
in 1 minute and 10 seconds
......@@ -15,6 +15,8 @@
#include <filesystem>
#include <fcntl.h>
#include <QtDBus>
#include <QCoreApplication>
......@@ -316,8 +318,15 @@ QByteArray ExternalCommandHelper::ReadData(const QString& device, const qint64 o
}
QByteArray buffer;
QFile sourceDevice(device);
bool rval = readData(sourceDevice, buffer, offset, length);
QFile sourceDevice;
int fd = open(device.toLocal8Bit().constData(), O_NOFOLLOW);
  • Never closed?

  • Hmm yes, will fix this. Thank you. Though I need to move opening/closing outside this function and pass file descriptor.

Please register or sign in to reply
// Negative numbers are error codes
if (fd < 0) {
qWarning() << "Error: failed to open device " << device;
return QByteArray();
}
bool rval = sourceDevice.open(fd, QIODevice::ReadOnly | QIODevice::Unbuffered);
rval = rval && readData(sourceDevice, buffer, offset, length);
if (rval) {
return buffer;
}
......
Supports Markdown
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