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

Paul Jakma paul at clubi.ie
Fri Apr 1 23:34:55 BST 2005

On Fri, 1 Apr 2005, Andrew J. Schorr wrote:

> Or to take another example, look in
> zebra/if_ioctl_solaris.c:interface_list_ioctl().  It says:
>   ifp = if_get_by_name (lifreq->lifr_name);


> Looking at the definition of struct lifreq, it says:
> #define LIFNAMSIZ       32

ah, even more oops.

> struct  lifreq {
>        char    lifr_name[LIFNAMSIZ];           /* if name, e.g. "en0" */
> 	...
> }
> Interestingly, LIFNAMSIZ is larger than quagga INTERFACE_NAMSIZ (20 
> bytes).


> I'm not sure whether that means that Solaris can have interface 
> names up to 32 bytes.  And I'm not sure whether lifr_name is 
> guaranteed to have a '\0' termination char.

I wouldn't count on it. Not because of any guarantees solaris may or 
may not make, but simply cause its safer to assume not (as you point 

>  But in any case, the 
> safer call would look like this:
>   ifp = if_get_by_name_len(lifreq->lifr_name,
> 			    strnlen(lifreq->lifr_name,
> 				    sizeof(lifreq->lifr_name)));
> Then we would be 100% safe.  Certainly the existing code which 
> assumes that lifreq->lifr_name has a maximum length of 
> INTERFACE_NAMSIZ bytes does not appear to be correct...

Yep, you're right.

Paul Jakma	paul at clubi.ie	paul at jakma.org	Key ID: 64A2FF6A
Here I am, fifty-eight, and I still don't know what I want to be when
I grow up.
 		-- Peter Drucker

More information about the Quagga-dev mailing list