OpenSSHKey: when writing to agent, ensure comment string is at least one byte

This unbreaks adding keys to gpg-agent.

Signed-off-by: Steven Noonan <steven@uplinklabs.net>
This commit is contained in:
Steven Noonan 2018-03-07 20:43:26 -08:00 committed by Jonathan White
parent d156457405
commit dc1aead2a2
2 changed files with 19 additions and 2 deletions

View file

@ -268,10 +268,15 @@ void SSHAgent::databaseModeChanged(DatabaseWidget::Mode mode)
}
QByteArray keyData;
QString fileName;
if (settings.selectedType() == "attachment") {
keyData = e->attachments()->value(settings.attachmentName());
fileName = settings.attachmentName();
keyData = e->attachments()->value(fileName);
} else if (!settings.fileName().isEmpty()) {
QFile file(settings.fileName());
QFileInfo fileInfo(file);
fileName = fileInfo.fileName();
if (file.size() > 1024 * 1024) {
continue;
@ -302,6 +307,10 @@ void SSHAgent::databaseModeChanged(DatabaseWidget::Mode mode)
key.setComment(e->username());
}
if (key.comment().isEmpty()) {
key.setComment(fileName);
}
if (settings.removeAtDatabaseClose()) {
removeIdentityAtLock(key, uuid);
}