use of strncpy and strlen

Jeremy Allison jra at samba.org
Tue Jan 15 17:12:03 GMT 2002


On Wed, Jan 16, 2002 at 12:00:04PM +1100, Andrew Bartlett wrote:
> Benjamin Kuit wrote:
> > 
> > Not sure if the respective developers are aware of the problem, but
> > there are some occurances whereby people use Strncpy (or strncpy) with
> > strlen like this:
> > 
> > Strncpy(dest, src, strlen(src));
> > 
> > Instead of using the size of the destination buffer for the length
> > parameter.
> > 
> > The developers might aswell #undef strcpy and use it instead.
> > 
> > Just my 1 cents worth. =)
> 
> Yep, I fixed up a pile of these in passdb in HEAD, but they havn't made
> it to 2.2 yet.
> 
> Can you give a list?  These need to be squahed...

Andrew,

	When you do this - just remove StrnCpy and move to strlcpy -
that way we can get rid of the annoying -1 also.

Jeremy.




More information about the samba-technical mailing list