diff options
author | phk <phk@FreeBSD.org> | 1998-04-22 06:20:20 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1998-04-22 06:20:20 +0000 |
commit | 3aab9d8b31f075eaafd367b78fe31ac11c4cd234 (patch) | |
tree | 914cbfc04fb156cc4f9107a68b08e87ad84c654d | |
parent | cf01114fc439a6090f09b83c524c560a85b87cf3 (diff) | |
download | FreeBSD-src-3aab9d8b31f075eaafd367b78fe31ac11c4cd234.zip FreeBSD-src-3aab9d8b31f075eaafd367b78fe31ac11c4cd234.tar.gz |
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.
PR: 6379
Reviewed by: phk
Submitted by: Neal Fachan <kneel@ishiboo.com>
-rw-r--r-- | sbin/ipfw/ipfw.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/sbin/ipfw/ipfw.c b/sbin/ipfw/ipfw.c index d143d67..22407e6 100644 --- a/sbin/ipfw/ipfw.c +++ b/sbin/ipfw/ipfw.c @@ -16,7 +16,7 @@ * * NEW command line interface for IP firewall facility * - * $Id: ipfw.c,v 1.54 1998/02/12 00:57:06 alex Exp $ + * $Id: ipfw.c,v 1.55 1998/03/13 02:31:21 alex Exp $ * */ @@ -1179,6 +1179,7 @@ ipfw_main(ac,av) /* 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 @@ main(ac, av) 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 @@ main(ac, av) 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; |