From 45c27cda5806dd108c1f2ca44ccd4be66b0718ef Mon Sep 17 00:00:00 2001 From: ru Date: Fri, 25 Feb 2000 11:34:38 +0000 Subject: Remove the config file line length restriction. PR: 16900 Reviewed by: "Crist J. Clark" , jkh Approved by: jkh --- sbin/natd/natd.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'sbin/natd/natd.c') 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. -- cgit v1.1