diff options
author | Ian Dowse <iedowse@FreeBSD.org> | 2002-05-14 23:24:28 +0000 |
---|---|---|
committer | Ian Dowse <iedowse@FreeBSD.org> | 2002-05-14 23:24:28 +0000 |
commit | 91ca1a918f0fbaf41a17e04e7698b3663da87f0c (patch) | |
tree | eb202ba2c57877f1bf8423cfe112483bf976bd8e /usr.sbin/mountd | |
parent | e7b663eff21c5618f12a38a5c93e87e3599c81e3 (diff) | |
download | src-91ca1a918f0fbaf41a17e04e7698b3663da87f0c.tar.gz src-91ca1a918f0fbaf41a17e04e7698b3663da87f0c.zip |
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.
Notes
Notes:
svn path=/head/; revision=96622
Diffstat (limited to 'usr.sbin/mountd')
-rw-r--r-- | usr.sbin/mountd/mountd.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c index 3061d2f8d183..b219c76f0435 100644 --- a/usr.sbin/mountd/mountd.c +++ b/usr.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); } |