kern/107565: [ipfw] [patch] input string parsing mistake
Anishchuk, Igor
igor.anishchuk at f-secure.com
Fri Jan 5 12:40:26 PST 2007
The following reply was made to PR kern/107565; it has been noted by GNATS.
From: "Anishchuk, Igor" <igor.anishchuk at f-secure.com>
To: <bug-followup at FreeBSD.org>,
"Anishchuk, Igor" <igor.anishchuk at f-secure.com>
Cc:
Subject: Re: kern/107565: [ipfw] [patch] input string parsing mistake
Date: Fri, 5 Jan 2007 22:36:40 +0200
Hello!
I've found a little mistake in my workaround. The line
for(ti=3D0; ti<16 && p[ti] !=3D 0; ti++){
should be
for (ti=3D0; ti<16 && p && p[ti] !=3D 0; ti++){
Please change is ASAP otherwise segmentation fault will happen in some
conditions.
The complete, tested patch is:
--- /usr/src/sbin/ipfw/ipfw2.c Fri Jan 5 17:43:25 2007
***************
*** 2720,2725 ****
--- 2720,2733 ----
char *p =3D strpbrk(av, "/:,{");
int masklen;
char md;
+ char t[15];
+ int ti;
+
+ for (ti=3D0; ti<16 && p && p[ti] !=3D 0; ti++){
+ t[ti]=3Dp[ti+1];
+ if(t[ti] !=3D '.' && (t[ti] < '0' || t[ti] > '9'))
+ t[ti] =3D '\0';
+ }
if (p) {
md =3D *p;
***************
*** 2731,2741 ****
errx(EX_NOHOST, "hostname ``%s'' unknown", av);
switch (md) {
case ':':
! if (!inet_aton(p, (struct in_addr *)&d[1]))
errx(EX_DATAERR, "bad netmask ``%s''", p);
break;
case '/':
! masklen =3D atoi(p);
if (masklen =3D=3D 0)
d[1] =3D htonl(0); /* mask */
else if (masklen > 32)
--- 2739,2749 ----
errx(EX_NOHOST, "hostname ``%s'' unknown", av);
switch (md) {
case ':':
! if (!inet_aton(t, (struct in_addr *)&d[1]))
errx(EX_DATAERR, "bad netmask ``%s''", p);
break;
case '/':
! masklen =3D atoi(t);
if (masklen =3D=3D 0)
d[1] =3D htonl(0); /* mask */
else if (masklen > 32)
Thanks!
--=20
Igor Anishchuk
More information about the freebsd-ipfw
mailing list