[quagga-dev 3095] Re: bugs related to length of interface names
Andrew J. Schorr
aschorr at telemetry-investments.com
Sun Apr 3 00:30:53 BST 2005
On Sat, Apr 02, 2005 at 05:57:10PM -0500, Andrew J. Schorr wrote:
> I have fixed occurrences in lib, and some in zebra. But basically
> we now need to audit all uses of if_lookup_by_name and if_get_by_name
> and fix them. When I grep for 'if_.*by_name', I find 55 occurrences.
> Of those, 19 are in lib and are OK. But I could use some help
> with the others, particularly stuff in zebra, where I am not sure
> of the kernel interfaces. For example, I don't know what is correct for
> the various *BSD interfaces. Also, for netlink, is it guaranteed that
> interface names are always terminated with a '\0' char? Or is there a buffer
> length limitation?
OK, I think I may have fixed everything outside of the zebra daemon. But
I am uncertain about the following lines of code:
./zebra/if_ioctl.c:105: ifp = if_get_by_name (ifreq->ifr_name);
./zebra/if_ioctl.c:116: ifp = if_get_by_name (ifreq->ifr_name);
./zebra/if_ioctl.c:227: ifp = if_lookup_by_name (ifap->ifa_name);
./zebra/if_proc.c:161: ifp = if_get_by_name (name);
./zebra/if_proc.c:195: ifp = if_get_by_name (name);
./zebra/if_proc.c:237: ifp = if_get_by_name (ifname);
./zebra/kernel_socket.c:204: ifp = if_get_by_name (ifan->ifan_name);
./zebra/rt_netlink.c:533: ifp = if_get_by_name (name);
./zebra/rt_netlink.c:1003: ifp = if_lookup_by_name (name);
./zebra/rt_netlink.c:1008: ifp = if_get_by_name (name);
./zebra/rt_netlink.c:1045: ifp = if_lookup_by_name (name);
This is platform-specific stuff and depends on platform conventions
regarding buffer sizes and termination with '\0'.
I'm guessing the ifreq->ifr_name references should have a max length of
sizeof(ifreq->ifr_name). Would the same apply to ifap->ifa_name and
ifan->ifan_name? Or are they pointers?
And in if_proc.c and rt_netlink.c, are those names guaranteed to be
terminated with a NUL char?
More information about the Quagga-dev