From gfb@vta.com  Sat May 14 16:30:01 2005
Return-Path: <gfb@vta.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 0341116A4D0
	for <bug-followup@FreeBSD.org>; Sat, 14 May 2005 16:30:01 +0000 (GMT)
Received: from vtamail.vta.com (vta.com [208.199.187.6])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 7D84943D62
	for <bug-followup@FreeBSD.org>; Sat, 14 May 2005 16:30:00 +0000 (GMT)
	(envelope-from gfb@vta.com)
Received: from bozo (c-24-98-61-110.hsd1.ga.comcast.net [24.98.61.110])
	(authenticated bits=0)
	by vtamail.vta.com (8.12.9/8.12.9) with ESMTP id j4EGTtbs058256
	for <bug-followup@FreeBSD.org>; Sat, 14 May 2005 12:29:57 -0400 (EDT)
	(envelope-from gfb@vta.com)
Message-Id: <000001c558a2$15806750$961fa8c0@bozo>
Date: Sat, 14 May 2005 12:29:19 -0400
From: "Guy F. Boyd" <gfb@vta.com>
Reply-To: <gfb@vta.com>
To: <bug-followup@FreeBSD.org>
Subject: [PATCH] bin/80913: /sbin/ipfw2 silently discards MAC addr arg with improper

>Number:         81027
>Category:       bin
>Synopsis:       [PATCH] bin/80913: /sbin/ipfw2 silently discards MAC addr arg with improper
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat May 14 16:30:11 GMT 2005
>Closed-Date:    Mon May 16 08:10:05 GMT 2005
>Last-Modified:  Mon May 16 12:10:02 GMT 2005
>Originator:     
>Release:        
>Organization:
>Environment:
>Description:
 This is a multi-part message in MIME format.
 
 ------=_NextPart_000_0001_01C55880.8E704DF0
 Content-Type: text/plain;
 	charset="iso-8859-1"
 Content-Transfer-Encoding: 7bit
 
 
 
 *** ipfw2.c.orig	Tue May 10 18:29:23 2005
 --- ipfw2.c	Tue May 10 19:33:26 2005
 ***************
 *** 2630,2649 ****
 --- 2630,2683 ----
 
   /*
    * Fetch and add the MAC address and type, with masks.
 This generates one or
    * two microinstructions, and returns the pointer to the
 last one.
    */
   static ipfw_insn *
   add_mac(ipfw_insn *cmd, int ac, char *av[])
   {
   	ipfw_insn_mac *mac;
 
 + /*
 +  * Check for invalid characters if ':' delimiter is
 detected in av[].
 +  * The rule may otherwise produce unintended results if it
 silently
 +  * discards the improperly formatted supplied mac address.
 +  */
 +
 + #define CHECK_VALID_MACADDR_CHARS
 + #ifdef CHECK_VALID_MACADDR_CHARS
 + 	int i,j;
 + 	for (i = 0; i < ac; i++)
 + 	{
 + 		if (strnstr(av[i], ":", sizeof(av[i])))
 + 		{
 + 			for (j = 0; j < strlen(av[i]); j++)
 + 			{
 + 				if (av[i][j] < '0')
 + 					errx(EX_DATAERR, "Invalid MAC addr %s", av[i] );
 + 				if (av[i][j] > ':')
 + 				{
 + 					if (av[i][j] < 'A')
 + 						errx(EX_DATAERR, "Invalid MAC addr %s", av[i] );
 + 					if (av[i][j] > 'F')
 + 					{
 + 						if (av[i][j] < 'a')
 + 							errx(EX_DATAERR, "Invalid MAC addr %s", av[i] );
 + 						if (av[i][j] > 'f')
 + 							errx(EX_DATAERR, "Invalid MAC addr %s", av[i] );
 + 					}
 + 				}
 + 			}
 + 		}
 + 	}
 + #endif CHECK_VALID_MACADDR_CHARS
 +
   	if (ac < 2)
   		errx(EX_DATAERR, "MAC dst src");
 
   	cmd->opcode = O_MACADDR2;
   	cmd->len = (cmd->len & (F_NOT | F_OR)) |
 F_INSN_SIZE(ipfw_insn_mac);
 
   	mac = (ipfw_insn_mac *)cmd;
   	get_mac_addr_mask(av[0], mac->addr, mac->mask);	/* dst */
   	get_mac_addr_mask(av[1], &(mac->addr[6]),
 &(mac->mask[6])); /* src */
   	return cmd;
 
 ------=_NextPart_000_0001_01C55880.8E704DF0
 Content-Type: application/octet-stream;
 	name="ipfw2.diff"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment;
 	filename="ipfw2.diff"
 
 *** ipfw2.c.orig	Tue May 10 18:29:23 2005
 --- ipfw2.c	Tue May 10 19:33:26 2005
 ***************
 *** 2630,2649 ****
 --- 2630,2683 ----
  =20
   /*
    * Fetch and add the MAC address and type, with masks. This generates =
 one or
    * two microinstructions, and returns the pointer to the last one.
    */
   static ipfw_insn *
   add_mac(ipfw_insn *cmd, int ac, char *av[])
   {
   	ipfw_insn_mac *mac;
  =20
 + /*
 +  * Check for invalid characters if ':' delimiter is detected in av[].
 +  * The rule may otherwise produce unintended results if it silently
 +  * discards the improperly formatted supplied mac address.
 +  */
 +=20
 + #define CHECK_VALID_MACADDR_CHARS
 + #ifdef CHECK_VALID_MACADDR_CHARS
 + 	int i,j;
 + 	for (i =3D 0; i < ac; i++)=20
 + 	{
 + 		if (strnstr(av[i], ":", sizeof(av[i])))=20
 + 		{
 + 			for (j =3D 0; j < strlen(av[i]); j++)=20
 + 			{
 + 				if (av[i][j] < '0')=20
 + 					errx(EX_DATAERR, "Invalid MAC addr %s", av[i] );
 + 				if (av[i][j] > ':') =20
 + 				{
 + 					if (av[i][j] < 'A')=20
 + 						errx(EX_DATAERR, "Invalid MAC addr %s", av[i] );
 + 					if (av[i][j] > 'F') =20
 + 					{
 + 						if (av[i][j] < 'a') =20
 + 							errx(EX_DATAERR, "Invalid MAC addr %s", av[i] );
 + 						if (av[i][j] > 'f') =20
 + 							errx(EX_DATAERR, "Invalid MAC addr %s", av[i] );
 + 					}=09
 + 				}
 + 			}
 + 		}
 + 	}
 + #endif CHECK_VALID_MACADDR_CHARS
 +=20
   	if (ac < 2)
   		errx(EX_DATAERR, "MAC dst src");
  =20
   	cmd->opcode =3D O_MACADDR2;
   	cmd->len =3D (cmd->len & (F_NOT | F_OR)) | =
 F_INSN_SIZE(ipfw_insn_mac);
  =20
   	mac =3D (ipfw_insn_mac *)cmd;
   	get_mac_addr_mask(av[0], mac->addr, mac->mask);	/* dst */
   	get_mac_addr_mask(av[1], &(mac->addr[6]), &(mac->mask[6])); /* src */
   	return cmd;
 
 ------=_NextPart_000_0001_01C55880.8E704DF0--
 
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Mon May 16 08:08:39 GMT 2005 
State-Changed-Why:  
Misfiled followup to bin/80913; content migrated.  However, I should 
note that the PR showed up with the evil 'quoted-printable', so the 
patches are probably mangled beyond use. 


Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon May 16 08:08:39 GMT 2005 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=81027 

From: "Guy F. Boyd" <gfb@vta.com>
To: <bug-followup@FreeBSD.org>, <gfb@vta.com>
Cc:  
Subject: Re: bin/81027: [PATCH] bin/80913: /sbin/ipfw2 silently discards MAC addr arg with improper
Date: Mon, 16 May 2005 07:59:32 -0400

 Patch re-submitted, posted for retrieval here:
 
 ftp://darth.vta.com/pub/FreeBSD/pr-bin-81027/ipfw2-diff.asc
 
 
 Guy F. Boyd
 Software Engineering
 VTA Technologies
 <gfb@vta.com>
 
>Unformatted:
