Date: Thu, 16 Sep 2004 04:02:18 -0000 From: Pyun YongHyeon <yongari@kt-is.co.kr> To: pf4freebsd@freelists.org Subject: [pf4freebsd] Re: pfflowd port Message-ID: <20040224023435.GB4129@kt-is.co.kr> In-Reply-To: <20040224012947.GA99698@kate.fud.org.nz> References: <20040224001503.GA99464@kate.fud.org.nz> <200402240135.55752.max@love2party.net> <20040224012947.GA99698@kate.fud.org.nz>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Feb 24, 2004 at 02:29:47PM +1300, Andrew Thompson wrote: > On Tue, Feb 24, 2004 at 01:35:55AM +0100, Max Laier wrote: > > On Tuesday 24 February 2004 01:15, Andrew Thompson wrote: > > > Hi all, > > > > > > I have created a port for pfflowd and thought i'd get feedback bef= ore > > > submitting a PR. > > > > > > It can be found @ > > > > > > http://www.fud.org.nz/pfflowd-port.tar.gz > >=20 > > Okay, some feedback: > > 1) You copied from security/pf (which is okay), but you should updat= e the=20 > > pkg-descr. >=20 > oops, my bad. >=20 > > 2) pkg-plist is empty, but should contain: > > sbin/pfflowd > > etc/rc.d/pfflowd.sh.sample >=20 > oops again :) >=20 > > 3) Not sure what the patch for pfflowd.c should do. What is wrong wi= th the=20 > > check for invalid ports? >=20 > It generated a gcc warning, as addr->sin_port is a uint16_t which cant > be negative or >65536. -Werror made this fatal. >=20 How about this? parse_hostport(const char *s, struct sockaddr_in *addr) { char *host, *port; +#if defined(__FreeBSD__) + int val; +#endif =20 if ((host =3D strdup(s)) =3D=3D NULL) { fprintf(stderr, "Out of memory\n"); @@ -197,12 +204,22 @@ } *(port - 1) =3D '\0'; addr->sin_family =3D AF_INET; +#if defined(__FreeBSD__) + val =3D atoi(port); + if (val <=3D 0 || val >=3D 65536) { + fprintf(stderr, "Invalid -n port.\n"); + usage(); + exit(1); + } + addr->sin_port =3D (in_port_t)val; +#else addr->sin_port =3D atoi(port); if (addr->sin_port <=3D 0 || addr->sin_port >=3D 65536) { fprintf(stderr, "Invalid -n port.\n"); usage(); exit(1); } +#endif addr->sin_port =3D htons(addr->sin_port); if (inet_aton(host, &addr->sin_addr) =3D=3D 0) { fprintf(stderr, "Invalid -n host.\n"); Memeber sin_port is 'u_int16_t' type. So checking with <=3D0 or >=3D 65536 does not work at all. > > 4) Maybe get the pidfile.{c,h} from us (include/support/) and add th= em=20 > > instead of just removing <util.h> and pidfile support. >=20 > Thanks, I wasnt sure where pidfile() came from. >=20 >=20 > Andy >=20 Regards, Pyun YongHyeon --=20 Pyun YongHyeon <http://www.kr.freebsd.org/~yongari>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040224023435.GB4129>