| Summary: | Bad error flagging in natd(8) config file read | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Base System | Reporter: | Crist J. Clark <cjc> | ||||
| Component: | bin | Assignee: | ru <ru> | ||||
| Status: | Closed FIXED | ||||||
| Severity: | Affects Only Me | ||||||
| Priority: | Normal | ||||||
| Version: | 3.4-STABLE | ||||||
| Hardware: | Any | ||||||
| OS: | Any | ||||||
| Attachments: |
|
||||||
Responsible Changed From-To: freebsd-bugs->ru Will fix it tomorrow. State Changed From-To: open->closed Fixed in 4.0-current and 3.4-stable. |
natd(8) will choke and die on a configuration file if the last line of the file does not end in a newline. It does not matter whether the line is even a natd option. natd will bail if the last line is a comment and does not end in a newline (which is how I found this). That in itself is not necessarily a bug. What is a bug is that natd improperly flags the error as, natd: config line too long: <last line> Fix: The workaround is to realize natd is misinterpretting the situation and put a newline in your config file. There are two ways to have natd properly handle this. (1) Flag a file with no newline on the last line, or (2) accept a file with no newline on the last line. Here is the patch for (1), However, here is the patch for my preference, (2), I tested a little, but they are quick fixes. I may have overlooked something.--j9OgXhynLLrd9KtYgu5f1LLcsi7jID6ON4E0le3bL3Ebr0U9 Content-Type: text/plain; name="file.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="file.diff" --- /usr/src/sbin/natd/natd.c Fri Jan 28 04:02:05 2000 +++ natd.c Mon Feb 21 23:03:36 2000 @@ -1263,7 +1263,10 @@ ptr = strchr (buf, '\n'); - if (!ptr) - errx (1, "config line too long: %s", buf); + if (!ptr) { + ptr = strchr (buf, '\0'); + if ( ptr && ( ( ptr - buf + 1 ) < sizeof (buf) ) ) + errx (1, "no newline at end of config file: %s", buf); + else + errx (1, "config line too long: %s", buf); + } *ptr = '\0'; How-To-Repeat: This will occur anytime a natd configuration file is valid until the last line without a newline.