From 3aab9d8b31f075eaafd367b78fe31ac11c4cd234 Mon Sep 17 00:00:00 2001 From: phk Date: Wed, 22 Apr 1998 06:20:20 +0000 Subject: 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 --- sbin/ipfw/ipfw.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sbin/ipfw') 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; -- cgit v1.1