Skip to content

Commit

Permalink
fix: base64 the nonce to avoid null terminators
Browse files Browse the repository at this point in the history
  • Loading branch information
tufteddeer committed Aug 11, 2024
1 parent 78de026 commit 6bcc6b0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sshconnect.c
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,11 @@ ra_ssh_service_accept(int type, u_int32_t seq, struct ssh *ssh) {
char nonce[RA_SSH_NONCE_SIZE];
arc4random_buf(nonce, RA_SSH_NONCE_SIZE);

ssh->ra_ssh_nonce = nonce;
// base64 encoding is not strictly necessary, but makes debug printing easier and ensures that it contains no \0
// so it can be used like a cstring. the nonce is used as-is and not decoded again.
struct sshbuf *b = sshbuf_new();
sshbuf_put(b, nonce, RA_SSH_NONCE_SIZE);
ssh->ra_ssh_nonce = sshbuf_dtob64_string(b, 0);

debug_f("requesting RA SSH token with nonce: %s", ssh->ra_ssh_nonce);
int r;
Expand Down

0 comments on commit 6bcc6b0

Please sign in to comment.