diff options
author | markus@openbsd.org <markus@openbsd.org> | 2018-06-06 18:29:18 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2018-06-07 04:34:05 +1000 |
commit | 7f90635216851f6cb4bf3999e98b825f85d604f8 (patch) | |
tree | ac302db18a71c1e3c5d9077d1a820e37fbc2b9b5 /readconf.c | |
parent | 392db2bc83215986a91c0b65feb0e40e7619ce7e (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 'readconf.c')
-rw-r--r-- | readconf.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/readconf.c b/readconf.c index 9c4a234b5..733b67f76 100644 --- a/readconf.c +++ b/readconf.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: readconf.c,v 1.288 2018/06/01 03:33:53 djm Exp $ */ | 1 | /* $OpenBSD: readconf.c,v 1.289 2018/06/06 18:29:18 markus Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -1728,7 +1728,8 @@ read_config_file_depth(const char *filename, struct passwd *pw, | |||
1728 | int flags, int *activep, int depth) | 1728 | int flags, int *activep, int depth) |
1729 | { | 1729 | { |
1730 | FILE *f; | 1730 | FILE *f; |
1731 | char line[4096]; | 1731 | char *line = NULL; |
1732 | size_t linesize = 0; | ||
1732 | int linenum; | 1733 | int linenum; |
1733 | int bad_options = 0; | 1734 | int bad_options = 0; |
1734 | 1735 | ||
@@ -1755,15 +1756,14 @@ read_config_file_depth(const char *filename, struct passwd *pw, | |||
1755 | * on/off by Host specifications. | 1756 | * on/off by Host specifications. |
1756 | */ | 1757 | */ |
1757 | linenum = 0; | 1758 | linenum = 0; |
1758 | while (fgets(line, sizeof(line), f)) { | 1759 | while (getline(&line, &linesize, f) != -1) { |
1759 | /* Update line number counter. */ | 1760 | /* Update line number counter. */ |
1760 | linenum++; | 1761 | linenum++; |
1761 | if (strlen(line) == sizeof(line) - 1) | ||
1762 | fatal("%s line %d too long", filename, linenum); | ||
1763 | if (process_config_line_depth(options, pw, host, original_host, | 1762 | if (process_config_line_depth(options, pw, host, original_host, |
1764 | line, filename, linenum, activep, flags, depth) != 0) | 1763 | line, filename, linenum, activep, flags, depth) != 0) |
1765 | bad_options++; | 1764 | bad_options++; |
1766 | } | 1765 | } |
1766 | free(line); | ||
1767 | fclose(f); | 1767 | fclose(f); |
1768 | if (bad_options > 0) | 1768 | if (bad_options > 0) |
1769 | fatal("%s: terminating, %d bad configuration options", | 1769 | fatal("%s: terminating, %d bad configuration options", |