summaryrefslogtreecommitdiff
path: root/ssh-keyscan.c
diff options
context:
space:
mode:
Diffstat (limited to 'ssh-keyscan.c')
-rw-r--r--ssh-keyscan.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/ssh-keyscan.c b/ssh-keyscan.c
index 381fb0844..38b1c548b 100644
--- a/ssh-keyscan.c
+++ b/ssh-keyscan.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-keyscan.c,v 1.119 2018/03/02 21:40:15 jmc Exp $ */ 1/* $OpenBSD: ssh-keyscan.c,v 1.120 2018/06/06 18:29:18 markus Exp $ */
2/* 2/*
3 * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>. 3 * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>.
4 * 4 *
@@ -646,9 +646,9 @@ main(int argc, char **argv)
646{ 646{
647 int debug_flag = 0, log_level = SYSLOG_LEVEL_INFO; 647 int debug_flag = 0, log_level = SYSLOG_LEVEL_INFO;
648 int opt, fopt_count = 0, j; 648 int opt, fopt_count = 0, j;
649 char *tname, *cp, line[NI_MAXHOST]; 649 char *tname, *cp, *line = NULL;
650 size_t linesize = 0;
650 FILE *fp; 651 FILE *fp;
651 u_long linenum;
652 652
653 extern int optind; 653 extern int optind;
654 extern char *optarg; 654 extern char *optarg;
@@ -769,11 +769,8 @@ main(int argc, char **argv)
769 else if ((fp = fopen(argv[j], "r")) == NULL) 769 else if ((fp = fopen(argv[j], "r")) == NULL)
770 fatal("%s: %s: %s", __progname, argv[j], 770 fatal("%s: %s: %s", __progname, argv[j],
771 strerror(errno)); 771 strerror(errno));
772 linenum = 0;
773 772
774 while (read_keyfile_line(fp, 773 while (getline(&line, &linesize, fp) != -1) {
775 argv[j] == NULL ? "(stdin)" : argv[j], line, sizeof(line),
776 &linenum) != -1) {
777 /* Chomp off trailing whitespace and comments */ 774 /* Chomp off trailing whitespace and comments */
778 if ((cp = strchr(line, '#')) == NULL) 775 if ((cp = strchr(line, '#')) == NULL)
779 cp = line + strlen(line) - 1; 776 cp = line + strlen(line) - 1;
@@ -798,6 +795,7 @@ main(int argc, char **argv)
798 795
799 fclose(fp); 796 fclose(fp);
800 } 797 }
798 free(line);
801 799
802 while (optind < argc) 800 while (optind < argc)
803 do_host(argv[optind++]); 801 do_host(argv[optind++]);