From owner-freebsd-bugs Tue Apr 21 18:00:04 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id SAA06242 for freebsd-bugs-outgoing; Tue, 21 Apr 1998 18:00:04 -0700 (PDT) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: (from gnats@localhost) by hub.freebsd.org (8.8.8/8.8.8) id SAA06232; Tue, 21 Apr 1998 18:00:01 -0700 (PDT) (envelope-from gnats) Received: from bleep.ishiboo.com (user11007@bleep.ishiboo.com [199.79.133.2]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id AAA05794 for ; Wed, 22 Apr 1998 00:56:44 GMT (envelope-from kneel@ishiboo.com) Received: (qmail 10338 invoked by uid 1001); 22 Apr 1998 01:56:58 -0000 Message-Id: <19980422015657.16212.qmail@bleep.ishiboo.com> Date: 22 Apr 1998 01:56:57 -0000 From: kneel@ishiboo.com To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: bin/6379: ipfw parsing errors Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >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