diff options
author | iedowse <iedowse@FreeBSD.org> | 2002-05-14 23:24:28 +0000 |
---|---|---|
committer | iedowse <iedowse@FreeBSD.org> | 2002-05-14 23:24:28 +0000 |
commit | 36cd292d7d6aabeb37153a23e56edf19634ea118 (patch) | |
tree | eb202ba2c57877f1bf8423cfe112483bf976bd8e /sbin/mountd | |
parent | 957e7d4f00a9759b34eeeaa7e56e0ecaf8866e71 (diff) | |
download | FreeBSD-src-36cd292d7d6aabeb37153a23e56edf19634ea118.zip FreeBSD-src-36cd292d7d6aabeb37153a23e56edf19634ea118.tar.gz |
Use fgetln to remove the static limit on the length of lines in
/etc/exports. Oversized lines were unlikely due to the large 10k
limit, but any found would cause mountd to exit with an error. Also
fix one or two compiler warnings.
Diffstat (limited to 'sbin/mountd')
-rw-r--r-- | sbin/mountd/mountd.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/sbin/mountd/mountd.c b/sbin/mountd/mountd.c index 3061d2f..b219c76 100644 --- a/sbin/mountd/mountd.c +++ b/sbin/mountd/mountd.c @@ -54,6 +54,8 @@ static const char rcsid[] = #include <sys/stat.h> #include <sys/syslog.h> #include <sys/sysctl.h> +#include <sys/linker.h> +#include <sys/module.h> #include <rpc/rpc.h> #include <rpc/pmap_clnt.h> @@ -268,7 +270,7 @@ main(argc, argv) int udpsock, tcpsock, udp6sock, tcp6sock; int xcreated = 0, s; int one = 1; - int c, error; + int c; udp6conf = tcp6conf = NULL; udp6sock = tcp6sock = NULL; @@ -874,8 +876,8 @@ put_exlist(dp, xdrsp, adp, putdefp) return (0); } -#define LINESIZ 10240 -char line[LINESIZ]; +char *line; +int linesize; FILE *exp_file; /* @@ -1997,7 +1999,7 @@ int get_line() { char *p, *cp; - int len; + size_t len; int totlen, cont_line; /* @@ -2006,9 +2008,8 @@ get_line() p = line; totlen = 0; do { - if (fgets(p, LINESIZ - totlen, exp_file) == NULL) + if ((p = fgetln(exp_file, &len)) == NULL) return (0); - len = strlen(p); cp = p + len - 1; cont_line = 0; while (cp >= p && @@ -2022,15 +2023,15 @@ get_line() *++cp = ' '; len++; } - *++cp = '\0'; - if (len > 0) { - totlen += len; - if (totlen >= LINESIZ) { - syslog(LOG_ERR, "exports line too long"); - exit(2); - } - p = cp; + if (linesize < len + totlen + 1) { + linesize = len + totlen + 1; + line = realloc(line, linesize); + if (line == NULL) + out_of_mem(); } + memcpy(line + totlen, p, len); + totlen += len; + line[totlen] = '\0'; } while (totlen == 0 || cont_line); return (1); } |