=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/hostfile.c,v retrieving revision 1.71 retrieving revision 1.72 diff -u -r1.71 -r1.72 --- src/usr.bin/ssh/hostfile.c 2017/05/31 09:15:42 1.71 +++ src/usr.bin/ssh/hostfile.c 2018/06/06 18:29:18 1.72 @@ -1,4 +1,4 @@ -/* $OpenBSD: hostfile.c,v 1.71 2017/05/31 09:15:42 deraadt Exp $ */ +/* $OpenBSD: hostfile.c,v 1.72 2018/06/06 18:29:18 markus Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -660,14 +660,14 @@ const char *host, const char *ip, u_int options) { FILE *f; - char line[8192], oline[8192], ktype[128]; + char *line = NULL, ktype[128]; u_long linenum = 0; char *cp, *cp2; u_int kbits; int hashed; int s, r = 0; struct hostkey_foreach_line lineinfo; - size_t l; + size_t linesize = 0, l; memset(&lineinfo, 0, sizeof(lineinfo)); if (host == NULL && (options & HKF_WANT_MATCH) != 0) @@ -676,15 +676,16 @@ return SSH_ERR_SYSTEM_ERROR; debug3("%s: reading file \"%s\"", __func__, path); - while (read_keyfile_line(f, path, line, sizeof(line), &linenum) == 0) { + while (getline(&line, &linesize, f) != -1) { + linenum++; line[strcspn(line, "\n")] = '\0'; - strlcpy(oline, line, sizeof(oline)); sshkey_free(lineinfo.key); memset(&lineinfo, 0, sizeof(lineinfo)); lineinfo.path = path; lineinfo.linenum = linenum; - lineinfo.line = oline; + free(lineinfo.line); + lineinfo.line = xstrdup(line); lineinfo.marker = MRK_NONE; lineinfo.status = HKF_STATUS_OK; lineinfo.keytype = KEY_UNSPEC; @@ -823,6 +824,8 @@ break; } sshkey_free(lineinfo.key); + free(lineinfo.line); + free(line); fclose(f); return r; }