[quagga-dev 3093] Re: bugs related to length of interface names

Andrew J. Schorr aschorr at telemetry-investments.com
Sat Apr 2 23:57:10 BST 2005


On Sat, Apr 02, 2005 at 08:00:23AM +0100, Paul Jakma wrote:
> On Fri, 1 Apr 2005, Andrew J. Schorr wrote:
> 
> >And I'm declaring it in lib/str.h.  But I wonder why "str.h" is not 
> >included by zebra.h?  Since zebra.h includes string.h and stdio.h, 
> >it seems to me that it should just go ahead and also include 
> >lib/str.h to pick up any functions that may be missing on this 
> >platform.
> 
> Seems sensible.

Done.

> >2. Regarding the new function names: is the decision to use an _len
> >suffix?  As in if_lookup_by_name_len and if_get_by_name_len?  Or is
> >there some shorter name that would be reasonable?
> 
> Hmm, I don't know. Take your pick. But deciding what colour to paint 
> this shed could be a show stopper ;).

OK, I added these 2 new functions: if_lookup_by_name_len, and
if_get_by_name_len.  Note that the 2nd argument should be the actual
length of the interface name being passed, not the maximum length.
So typical invocations will use strnlen to calculate the 2nd argument.

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?

Anyway, my goal is to change the regular if_lookup_by_name and if_get_by_name
functions to treat the argument as a NUL-terminated string.  So any
code that has implicit assumptions about maximum string lengths should
be switched to use the new if_*_by_name_len functions.  After that is done,
we can fix the old functions.

Does that make sense?

Regards,
Andy



More information about the Quagga-dev mailing list