diff options
author | markus@openbsd.org <markus@openbsd.org> | 2018-06-06 20:29:18 +0200 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2018-06-06 20:34:05 +0200 |
commit | 7f90635216851f6cb4bf3999e98b825f85d604f8 (patch) | |
tree | ac302db18a71c1e3c5d9077d1a820e37fbc2b9b5 /authfile.c | |
parent | upstream: regress test for PermitOpen (diff) | |
download | openssh-7f90635216851f6cb4bf3999e98b825f85d604f8.tar.xz openssh-7f90635216851f6cb4bf3999e98b825f85d604f8.zip |
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 'authfile.c')
-rw-r--r-- | authfile.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/authfile.c b/authfile.c index 57dcd808c..c3a6345d3 100644 --- a/authfile.c +++ b/authfile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: authfile.c,v 1.128 2018/02/23 15:58:37 markus Exp $ */ +/* $OpenBSD: authfile.c,v 1.129 2018/06/06 18:29:18 markus Exp $ */ /* * Copyright (c) 2000, 2013 Markus Friedl. All rights reserved. * @@ -265,17 +265,15 @@ static int sshkey_try_load_public(struct sshkey *k, const char *filename, char **commentp) { FILE *f; - char line[SSH_MAX_PUBKEY_BYTES]; - char *cp; - u_long linenum = 0; + char *line = NULL, *cp; + size_t linesize = 0; int r; if (commentp != NULL) *commentp = NULL; if ((f = fopen(filename, "r")) == NULL) return SSH_ERR_SYSTEM_ERROR; - while (read_keyfile_line(f, filename, line, sizeof(line), - &linenum) != -1) { + while (getline(&line, &linesize, f) != -1) { cp = line; switch (*cp) { case '#': @@ -299,11 +297,13 @@ sshkey_try_load_public(struct sshkey *k, const char *filename, char **commentp) if (*commentp == NULL) r = SSH_ERR_ALLOC_FAIL; } + free(line); fclose(f); return r; } } } + free(line); fclose(f); return SSH_ERR_INVALID_FORMAT; } @@ -447,19 +447,18 @@ sshkey_in_file(struct sshkey *key, const char *filename, int strict_type, int check_ca) { FILE *f; - char line[SSH_MAX_PUBKEY_BYTES]; - char *cp; - u_long linenum = 0; + char *line = NULL, *cp; + size_t linesize = 0; int r = 0; struct sshkey *pub = NULL; + int (*sshkey_compare)(const struct sshkey *, const struct sshkey *) = strict_type ? sshkey_equal : sshkey_equal_public; if ((f = fopen(filename, "r")) == NULL) return SSH_ERR_SYSTEM_ERROR; - while (read_keyfile_line(f, filename, line, sizeof(line), - &linenum) != -1) { + while (getline(&line, &linesize, f) != -1) { cp = line; /* Skip leading whitespace. */ @@ -491,6 +490,7 @@ sshkey_in_file(struct sshkey *key, const char *filename, int strict_type, } r = SSH_ERR_KEY_NOT_FOUND; out: + free(line); sshkey_free(pub); fclose(f); return r; |