KPasswordDialog / KPasswordEdit
michael.pyne at kdemail.net
Sun Jan 15 07:11:09 GMT 2006
On Saturday 14 January 2006 10:47, Daniel Molkentin wrote:
> silver bullet would be to check what it takes to make QSharedData and thus
> QString to use non-swapable memory, so we could just use QString or a
> derived class to handle passwords and other sensitive data in the future.
How about the placement new operator? It constructs an object in
pre-allocated memory instead of allocating new memory. So we could allocate
protected memory for any object we want, and then construct that object in
the unshared memory and basically avoid the problem altogether.
// Allocate space for object. Use secure_malloc() or something here.
void *buffer = malloc(1024);
// Note the "placement new" syntax.
QString *str = new (buffer) QString("StringString");
// It should actually work. ;)
cout << str->toUtf8().data() << endl;
// Don't use delete to free str, as it was not allocated by new.
// Run dtor manually instead.
// Deallocate the memory using appropriate function(s).
Still seems like a lot of trouble for something not called SSH or GnuPG, but
there you go.
- Michael Pyne
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
More information about the kde-core-devel