summaryrefslogtreecommitdiff
path: root/ssh-keyscan.c
diff options
context:
space:
mode:
authormarkus@openbsd.org <markus@openbsd.org>2018-06-06 18:29:18 +0000
committerDamien Miller <djm@mindrot.org>2018-06-07 04:34:05 +1000
commit7f90635216851f6cb4bf3999e98b825f85d604f8 (patch)
treeac302db18a71c1e3c5d9077d1a820e37fbc2b9b5 /ssh-keyscan.c
parent392db2bc83215986a91c0b65feb0e40e7619ce7e (diff)
upstream: switch config file parsing to getline(3) as this avoids
static limits noted by gerhard@; ok dtucker@, djm@ OpenBSD-Commit-ID: 6d702eabef0fa12e5a1d75c334a8c8b325298b5c
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++]);