Subject: Re: chksniff
To: <>
From: Ignatios Souvatzis <is@netbsd.org>
List: tech-userlevel
Date: 03/22/2003 19:34:57
--VbJkn9YxBvnuCH5J
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi,

On Sat, Mar 22, 2003 at 05:00:40PM +0100, Douwe Kiela wrote:

> Hey, I wrote a small tool to check if network interfaces are in promiscuous
> mode,called chksniff. 
...
> 		if (ioctl(fd, SIOCGIFADDR, &ifr[num]) != 0) {
> 			continue;
> 		}
> 
> 		sin = (struct sockaddr_in *)&ifr[num].ifr_addr;
> 		sin->sin_family=AF_INET;
> 		printf("%s [%s]:\t", ifr[num].ifr_name, inet_ntoa(sin->sin_addr));

Ahem - that looks wrong to me:
- it's not guaranteed that it is AF_INET.
- you should check for what address type (and length) are really in there,
  (use the untyped struct sockaddr for clarity) instead of overwriting the
  value. 

Regards,
	-is

--VbJkn9YxBvnuCH5J
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (NetBSD)

iD8DBQE+fKzQPCRcZ/VMtk4RArHZAJ9jaS0vgMDE1j1BLHqwF9F6G0AP8gCgi96z
RqQJD6YAWlLWix6sPWYkfxs=
=mQuQ
-----END PGP SIGNATURE-----

--VbJkn9YxBvnuCH5J--