summaryrefslogtreecommitdiffstats
path: root/sbin/natd/natd.c
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2000-02-25 11:34:38 +0000
committerru <ru@FreeBSD.org>2000-02-25 11:34:38 +0000
commit45c27cda5806dd108c1f2ca44ccd4be66b0718ef (patch)
treedaacb22971ba1e40d96dbec570c1654b966c1d26 /sbin/natd/natd.c
parentc262f0727bd2d7279e4a87574d6f47f7ef1cd71a (diff)
downloadFreeBSD-src-45c27cda5806dd108c1f2ca44ccd4be66b0718ef.zip
FreeBSD-src-45c27cda5806dd108c1f2ca44ccd4be66b0718ef.tar.gz
Remove the config file line length restriction.
PR: 16900 Reviewed by: "Crist J. Clark" <cjclark@home.com>, jkh Approved by: jkh
Diffstat (limited to 'sbin/natd/natd.c')
-rw-r--r--sbin/natd/natd.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/sbin/natd/natd.c b/sbin/natd/natd.c
index 09cd257..6bc4c5d 100644
--- a/sbin/natd/natd.c
+++ b/sbin/natd/natd.c
@@ -1248,24 +1248,21 @@ static void ParseOption (const char* option, const char* parms, int cmdLine)
void ReadConfigFile (const char* fileName)
{
FILE* file;
- char buf[128];
+ char *buf;
+ size_t len;
char *ptr, *p;
char* option;
file = fopen (fileName, "r");
- if (!file) {
+ if (!file)
+ err(1, "cannot open config file %s", fileName);
- sprintf (buf, "Cannot open config file %s.\n", fileName);
- Quit (buf);
- }
-
- while (fgets (buf, sizeof (buf), file)) {
-
- ptr = strchr (buf, '\n');
- if (!ptr)
- errx (1, "config line too long: %s", buf);
-
- *ptr = '\0';
+ while ((buf = fgetln(file, &len)) != NULL) {
+ if (buf[len - 1] == '\n')
+ buf[len - 1] = '\0';
+ else
+ errx(1, "config file format error: "
+ "last line should end with newline");
/*
* Check for comments, strip off trailing spaces.
OpenPOWER on IntegriCloud