Skip to content

Commit

Permalink
OpenSSHKey: when writing to agent, ensure comment string is at least …
Browse files Browse the repository at this point in the history
…one byte

This unbreaks adding keys to gpg-agent.

Signed-off-by: Steven Noonan <[email protected]>
  • Loading branch information
tycho committed Mar 8, 2018
1 parent aa63277 commit fc1cab2
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/sshagent/OpenSSHKey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,18 @@ bool OpenSSHKey::writePrivate(BinaryStream& stream)
}
}

if (!stream.writeString(m_comment)) {
m_error = tr("Unexpected EOF when writing private key");
return false;
if (m_comment.length() == 0) {
// gpg-agent fails to understand zero-length comment strings, so we
// need to provide a string that is at least one character long.
if (!stream.writeString(QString(" "))) {
m_error = tr("Unexpected EOF when writing private key");
return false;
}
} else {
if (!stream.writeString(m_comment)) {
m_error = tr("Unexpected EOF when writing private key");
return false;
}
}

return true;
Expand Down

0 comments on commit fc1cab2

Please sign in to comment.