Commit 569a1640 authored by Gleb Popov's avatar Gleb Popov

Append NULL byte to every property of type QByteArray before returning it.

While Qt documentation states that QByteArray's are always NULL-terminated, the
terminator itself is not a part of the array and can only be observed when calling
QByteArray::data() method. This results in data passed over D-Bus to not be
NULL-terminated.

Submitted by: tijl (original patch)
parent 0664604b4f67
......@@ -79,13 +79,13 @@ QByteArray Block::preferredDevice() const
{
if(labels.empty())
return device();
return (QStringLiteral("/dev/") + labels[0]).toLocal8Bit();
return (QStringLiteral("/dev/") + labels[0]).toLocal8Bit() + '\0';
}
QByteArray Block::device() const
{
return (QStringLiteral("/dev/") + name).toLocal8Bit();
return (QStringLiteral("/dev/") + name).toLocal8Bit() + '\0';
}
......@@ -93,7 +93,7 @@ QByteArrayList Block::symlinks()
{
QByteArrayList r;
foreach(auto s, labels)
r << (QStringLiteral("/dev/") + s).toLocal8Bit();
r << (QStringLiteral("/dev/") + s).toLocal8Bit() + '\0';
return r;
}
......@@ -125,7 +125,17 @@ QString Block::hintName() const
QByteArrayList Block::mountPoints() const
{
return bFilesystem ? bFilesystem->mountPoints : QByteArrayList();
if(bFilesystem)
{
QByteArrayList r;
for(auto mp : bFilesystem->mountPoints)
r << mp + '\0';
return r;
}
return QByteArrayList();
}
......
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