Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do_fingerprint: reset comment = NULL in each line #407

Closed
wants to merge 1 commit into from

Conversation

mgkuhn
Copy link

@mgkuhn mgkuhn commented Jun 16, 2023

When running ssh-keygen -l on an input file that contains both
public keys with and without comment, then the indicator "no comment"
never appears again after the first comment. This is because in
do_fingerprint() the variable comment is initialized to NULL only
at the start of the function, but must actually be re-initialized for
each line read.

Demonstration of this bug:

$ cat bug
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBfpSaasTV3FbT+Ak92X5qL1UF3Nl0CPwWF/H3m/bBci
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ2rupphYfNkBJvdPCHcnBd/5Gq/VbQ+1VgvriXW1Oyp foo@bar
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE5zBpiRVC+ORSiXsyHdbi0adLR4eYVa1I8i2Kpu+cRZ

Expected behaviour:

$ ssh-keygen -l -f bug
256 SHA256:Rj/1gp8XmwdtWhcS46y8nC8d8fMYxhVuoqQ9y22goJk no comment (ED25519)
256 SHA256:tqCk14afznT2VHNkBPG3T8xtbPhd4Z/yNAcSWloX2Nw foo@bar (ED25519)
256 SHA256:cpUGYGuJjZ5tVYv02Mq+wFDtATo9O8vlPqoHsl3tako no comment (ED25519)

Actual behaviour:

$ ssh-keygen -l -f bug
256 SHA256:Rj/1gp8XmwdtWhcS46y8nC8d8fMYxhVuoqQ9y22goJk no comment (ED25519)
256 SHA256:tqCk14afznT2VHNkBPG3T8xtbPhd4Z/yNAcSWloX2Nw foo@bar (ED25519)
256 SHA256:cpUGYGuJjZ5tVYv02Mq+wFDtATo9O8vlPqoHsl3tako  (ED25519)

"no comment" is missing in the last line of output.

When running `ssh-keygen -l` on an input file that contains both
public keys with and without comment, then the indicator "no comment"
never appears again after the first comment. This is because in
`do_fingerprint()` the variable `comment` is initialized to NULL only
at the start of the function, but must actually be re-initialized for
each line read.

Demonstration of this bug:

$ cat bug
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBfpSaasTV3FbT+Ak92X5qL1UF3Nl0CPwWF/H3m/bBci
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ2rupphYfNkBJvdPCHcnBd/5Gq/VbQ+1VgvriXW1Oyp foo@bar
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE5zBpiRVC+ORSiXsyHdbi0adLR4eYVa1I8i2Kpu+cRZ

Expected behaviour:

$ ssh-keygen -l -f bug
256 SHA256:Rj/1gp8XmwdtWhcS46y8nC8d8fMYxhVuoqQ9y22goJk no comment (ED25519)
256 SHA256:tqCk14afznT2VHNkBPG3T8xtbPhd4Z/yNAcSWloX2Nw foo@bar (ED25519)
256 SHA256:cpUGYGuJjZ5tVYv02Mq+wFDtATo9O8vlPqoHsl3tako no comment (ED25519)

Actual behaviour:

$ ssh-keygen -l -f bug
256 SHA256:Rj/1gp8XmwdtWhcS46y8nC8d8fMYxhVuoqQ9y22goJk no comment (ED25519)
256 SHA256:tqCk14afznT2VHNkBPG3T8xtbPhd4Z/yNAcSWloX2Nw foo@bar (ED25519)
256 SHA256:cpUGYGuJjZ5tVYv02Mq+wFDtATo9O8vlPqoHsl3tako  (ED25519)

"no comment" is missing in the last line of output.
@djmdjm
Copy link
Contributor

djmdjm commented Jun 20, 2023

Applied upstream and merged back as b4ac435 - thanks!

@djmdjm djmdjm closed this Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants