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 /misc.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 'misc.c')
-rw-r--r-- | misc.c | 27 |
1 files changed, 1 insertions, 26 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: misc.c,v 1.127 2018/03/12 00:52:01 djm Exp $ */ | 1 | /* $OpenBSD: misc.c,v 1.128 2018/06/06 18:29:18 markus Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2000 Markus Friedl. All rights reserved. | 3 | * Copyright (c) 2000 Markus Friedl. All rights reserved. |
4 | * Copyright (c) 2005,2006 Damien Miller. All rights reserved. | 4 | * Copyright (c) 2005,2006 Damien Miller. All rights reserved. |
@@ -1005,31 +1005,6 @@ percent_expand(const char *string, ...) | |||
1005 | #undef EXPAND_MAX_KEYS | 1005 | #undef EXPAND_MAX_KEYS |
1006 | } | 1006 | } |
1007 | 1007 | ||
1008 | /* | ||
1009 | * Read an entire line from a public key file into a static buffer, discarding | ||
1010 | * lines that exceed the buffer size. Returns 0 on success, -1 on failure. | ||
1011 | */ | ||
1012 | int | ||
1013 | read_keyfile_line(FILE *f, const char *filename, char *buf, size_t bufsz, | ||
1014 | u_long *lineno) | ||
1015 | { | ||
1016 | while (fgets(buf, bufsz, f) != NULL) { | ||
1017 | if (buf[0] == '\0') | ||
1018 | continue; | ||
1019 | (*lineno)++; | ||
1020 | if (buf[strlen(buf) - 1] == '\n' || feof(f)) { | ||
1021 | return 0; | ||
1022 | } else { | ||
1023 | debug("%s: %s line %lu exceeds size limit", __func__, | ||
1024 | filename, *lineno); | ||
1025 | /* discard remainder of line */ | ||
1026 | while (fgetc(f) != '\n' && !feof(f)) | ||
1027 | ; /* nothing */ | ||
1028 | } | ||
1029 | } | ||
1030 | return -1; | ||
1031 | } | ||
1032 | |||
1033 | int | 1008 | int |
1034 | tun_open(int tun, int mode, char **ifname) | 1009 | tun_open(int tun, int mode, char **ifname) |
1035 | { | 1010 | { |