Date: 22 Apr 1998 01:56:57 -0000 From: kneel@ishiboo.com To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: bin/6379: ipfw parsing errors Message-ID: <19980422015657.16212.qmail@bleep.ishiboo.com>
index | next in thread | raw e-mail
>Number: 6379
>Category: bin
>Synopsis: ipfw parsing is broken when taking rules from a file
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Tue Apr 21 18:00:01 PDT 1998
>Last-Modified:
>Originator: Neal Fachan
>Organization:
Ishiboo!
>Release: All
>Environment:
>Description:
When ipfw reads its rules from an input file, the optind variable is
not reinitialized to 1 after calling getopt. This results in parsing
errors on all but the first rule. An added patch also allows '#'
comments at the end of a line.
>How-To-Repeat:
cat >> ipfw_rules << EOF
-f flush
show
EOF
ipfw ipfw_rules
>Fix:
--- ipfw.c.orig Thu Apr 16 20:16:34 1998
+++ ipfw.c Thu Apr 16 20:20:16 1998
@@ -1179,6 +1179,7 @@
/* Set the force flag for non-interactive processes */
do_force = !isatty(STDIN_FILENO);
+ optind = 1;
while ((ch = getopt(ac, av, "afqtN")) != -1)
switch(ch) {
case 'a':
@@ -1275,6 +1276,7 @@
if ((f = fopen(av[1], "r")) == NULL)
err(EX_UNAVAILABLE, "fopen: %s", av[1]);
while (fgets(buf, BUFSIZ, f)) {
+ char *p;
lineno++;
sprintf(linename, "Line %d", lineno);
@@ -1282,6 +1284,8 @@
if (*buf == '#')
continue;
+ if ((p = strchr(buf, '#')) != NULL)
+ *p = '\0';
for (i = 1, a = strtok(buf, WHITESP);
a && i < MAX_ARGS; a = strtok(NULL, WHITESP), i++)
args[i] = a;
--
Neal Fachan kneel@ishiboo.com
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980422015657.16212.qmail>
