Peter Memishian writes:
> 
>  > > DJM-2 usr/src/cmd/cmd-inet/sbin/netstrategy/netstrategy.c:204,242
>  > > 
>  > > I think these strncpy can be replaced with the safer strlcpy.
>  > 
>  > No.  These are actually correct.  lifr_name is a fixed-length array,
>  > and the fact that strncpy zeros out to the end of the array is a
>  > desirable feature.
> 
> There is no requirement I'm aware of that requires the rest of the
> interface name array to be zeroed.  Why is that desirable?  Yes, it's true
> that with strlcpy() you're restricted to an interface name of LIFNAMSIZ-1
> characters, but that seems unlikely to cause real-world problems.

That'd be the only reason.

The consumer of the string (the kernel) already has to be careful in
access because it can't trust user space buffers, so switching to
strlcpy over strncpy doesn't buy anything at all in terms of safety.
I guess it can be done (sacrificing that last byte) if someone feels
moved to do it, but I disagree that we should just automatically
change all strn* to strl*.

-- 
James Carlson, Solaris Networking              <[EMAIL PROTECTED]>
Sun Microsystems / 35 Network Drive        71.232W   Vox +1 781 442 2084
MS UBUR02-212 / Burlington MA 01803-2757   42.496N   Fax +1 781 442 1677
_______________________________________________
networking-discuss mailing list
[email protected]

Reply via email to