ssh-keyscan can take an existing known_hosts file as input, but only if it contains no comment-lines. To reproduce: echo '#' > khtest ssh-keyscan -f khtest Result: getaddrinfo #: Name or service not known Expected: Nothing happens
Created attachment 1806 [details] Patch to fix integer overflow in fgets() wrapper
As described in http://mid.gmane.org/20100306210548.GA32662@polymnia.sshunet.nl, ssh-keyscan may suffer an integer overflow when run on a file with ridiculously (> 2GB) long lines. The attached patch fixes this and also allows comments.
Created attachment 1868 [details] /home/djm/keyscan-uncrazy.diff use read_keyfile_line()\n\nWe already have a fgets() wrapper, let's use it.
Created attachment 1869 [details] /home/djm/keyscan-uncrazy.diff revised diff
Comment on attachment 1869 [details] /home/djm/keyscan-uncrazy.diff ugh, attached the wrong diff twice :(
Created attachment 1870 [details] /home/djm/keyscan-uncrazy.diff The original diff didn't correctly handle the case of "ssh-keyscan -f -" (it would SEGV or EINVAL on fopen). This one uses our existing wrapper for fgets().
Created attachment 1875 [details] Patch to fix ssh-keyscan The attached patch is a slight alteration of your (Damien's) patch. - these lines are not related to SSH_MAX_PUBKEY_BYTES, so just hardcode some reasonable value; - linenum should be per-file, not over all files; - fatal() on long lines instead of silently ignoring them.
(In reply to comment #7) > Created attachment 1875 [details] > Patch to fix ssh-keyscan > > The attached patch is a slight alteration of your (Damien's) patch. > > - these lines are not related to SSH_MAX_PUBKEY_BYTES, so just hardcode > some reasonable value; > - linenum should be per-file, not over all files; These are both valid points. > - fatal() on long lines instead of silently ignoring them. This one I don't care so much about.
I agree with Darren. The corresponding patch has been committed and will be in OpenSSH-5.6. Thanks!
Move resolved bugs to CLOSED after 5.7 release