Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 May 2000 12:40:03 -0700 (PDT)
From:      Darcy Buskermolen <darcy@ok-connect.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   bin/18351 ipfw add with no rule number returns the wrong rule number
Message-ID:  <200005021940.MAA53802@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/18351; it has been noted by GNATS.

From: Darcy Buskermolen <darcy@ok-connect.com>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: bin/18351 ipfw add with no rule number returns the wrong rule
  number
Date: Tue, 02 May 2000 12:40:52 -0700

 --=====================_957321652==_
 Content-Type: text/plain; charset="us-ascii"
 
 Attached is my patch hopefully someone with a bit more hackers time can
 review and clean up this code
 
 \\DB
 
 --=====================_957321652==_
 Content-Type: text/plain; charset="us-ascii"
 Content-Disposition: attachment; filename="ipfw.patch"
 
 *** ipfw.c.org	Tue May  2 12:04:11 2000
 --- ipfw.c	Tue May  2 12:02:28 2000
 ***************
 *** 1281,1300 ****
   	int ac;
   	char **av;
   {
   	struct ip_fw rule;
   	int i;
   	u_char proto;
   	struct protoent *pe;
   	int saw_xmrc = 0, saw_via = 0;
 ! 	
   	memset(&rule, 0, sizeof rule);
   
   	av++; ac--;
   
   	/* Rule number */
   	if (ac && isdigit(**av)) {
   		rule.fw_number = atoi(*av); av++; ac--;
   	}
   
   	/* Action */
   	if (ac > 1 && !strncmp(*av, "prob", strlen(*av) ) ) {
 --- 1281,1341 ----
   	int ac;
   	char **av;
   {
 +   /*
 + 	struct ip_fw *rules;
 + 
 + 
 + 	void *data = NULL;
 + 	int pcwidth = 0;
 + 	int bcwidth = 0;
 + 	int n, num = 0;
 + 
 +    */
 + 	struct dn_pipe *pipes;
 + 	int nbytes;
 + 
 + 
   	struct ip_fw rule;
 +         struct ip_fw *rules;
   	int i;
   	u_char proto;
   	struct protoent *pe;
 +         int num = 0;
   	int saw_xmrc = 0, saw_via = 0;
 ! 	void *data=NULL;
   	memset(&rule, 0, sizeof rule);
   
   	av++; ac--;
   
 + 	{
 + 		const int unit = do_pipe ? sizeof(*pipes) : sizeof(*rules);
 + 		const int ocmd = do_pipe ? IP_DUMMYNET_GET : IP_FW_GET;
 + 		int nalloc = 0;
 + 
 + 		while (num >= nalloc) {
 + 			nalloc = nalloc * 2 + 200;
 + 			nbytes = nalloc * unit;
 + 			if ((data = realloc(data, nbytes)) == NULL)
 + 				err(EX_OSERR, "realloc");
 + 			if (getsockopt(s, IPPROTO_IP, ocmd, data, &nbytes) < 0)
 + 				err(EX_OSERR, "getsockopt(IP_%s_GET)",
 + 				    do_pipe ? "DUMMYNET" : "FW");
 + 			num = nbytes / unit;
 + 		}
 + 	}
 + 
   	/* Rule number */
   	if (ac && isdigit(**av)) {
   		rule.fw_number = atoi(*av); av++; ac--;
   	}
 +         else {
 +         	rules = (struct ip_fw *) data;
 + 		num = 0;
 + 		while (rules[num].fw_number < 65535){
 + 			num++;
 +                 }
 +         	rule.fw_number = num;
 +         }
   
   	/* Action */
   	if (ac > 1 && !strncmp(*av, "prob", strlen(*av) ) ) {
 
 --=====================_957321652==_--
 
 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200005021940.MAA53802>