Wiping sensitive data in QML
Hello,
I am looking for a way to wipe properties of objects once the property is not needed any more. Reassigning unfortunately doesn't work (value is changed, but you can still find original values in memory, until the area is re-used by something else). Basically I'm looking for an equivalent of QByteArray::fill, but as I can't get to the properties themselves (only the copies), original values still dangle around the memory. Any ideas (on C++ or QML side) would be very welcome.
Re: Wiping sensitive data in QML
To answer my own question (and help anyone else looking for an (ugly) solution to the same problem):
In the end the problem actually turned out to be - how to modify QVariant string data directly. Turns out the biggest problem was in-place rewriting of QString data. I came up with a solution (though I don't really like it and would prefer something cleaner):
Code:
{
void *valuePtr = value.d.is_shared ? value.d.data.shared->ptr : static_cast<void *>(&(value.d.data.c));
QString *text
= reinterpret_cast<QString
*>
(valuePtr
);
QChar* txtPtr
= const_cast<QChar
*>
(text
->constData
());
//yes, const_cast constData(), as data() creates a modifiable copy for (int x = 0; x < text->size(); x++)
}
}