Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 Nov 1998 07:07:18 -0800 (PST)
From:      "Jonathan M. Bresler" <jmb>
To:        jmb@FreeBSD.ORG (Jonathan M. Bresler)
Cc:        hackers@FreeBSD.ORG
Subject:   Re: tun interfaces not returned by SIOCGIFCONF ??
Message-ID:  <199811291507.HAA07258@hub.freebsd.org>
In-Reply-To: <199811290603.WAA27066@hub.freebsd.org> from "Jonathan M. Bresler" at "Nov 28, 98 10:03:07 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
Jonathan M. Bresler wrote:
> ~~~~~~~~~~~~~~~~~~~~
> in this code snippit, i always call inet_ntoa() eventhough the argument
> may no be an address but rather other data.
> 
> code from nmap (printf()'s are my additions):
>         for (ifr = (struct ifreq *) pbuf;
>            ifr && *((char *) ifr) && ((char *) ifr) < pbuf + ifc.ifc_len;
>              ((*(char **) &ifr) += sizeof(ifr->ifr_name) + len)) {
>                 sin = (struct sockaddr_in *) & ifr->ifr_addr;
> printf("ifc_len: %d (currently at %u)\n", ifc.ifc_len, (char *)ifr - pbuf);
> printf("trying: %s: %s\n", ifr->ifr_name, inet_ntoa(sin->sin_addr));
>                 if (sin->sin_addr.s_addr == addr->s_addr) {
>                         /*
>                          * Stevens does this in UNP, so it may be useful in
>                          * some cases
>                          */
>                         if ((p = strchr(ifr->ifr_name, ':')))
>                                 *p = '\0';
>                         /*
>                          * If an app gives me less than 64 bytes, they
>                          * deserve to be overflowed!
>                          */ 
>                         strncpy(dev, ifr->ifr_name, 63);
>                         dev[63] = '\0';
>                         return 1;
>                 }
>         }

	the bug in the above code snippit is "len is always the same value".
	the for loop increment must be set each time through the loop.
	
	i'll prepare a patch for the port of nmap-1.5.1
jmb

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



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