[asterisk-dev] seanbright: tools/trunk r5656 - /tools/trunk/dahdi_monitor.c
Russell Bryant
russell at digium.com
Wed Jan 14 09:01:52 CST 2009
Kevin P. Fleming wrote:
> Sean Bright wrote:
>
>> The code in question is copying a string into the _middle_ of another
>> string, and strcpy would copy the null byte at the end of the source
>> string as well, resulting in the same situation we had with
>> dahdi_copy_string. strncpy allows us to specifically exclude the
>> terminator.
Oops. :)
> Then if you know exactly how many bytes you want to copy, and that the
> source string has that many bytes (you will not run off the end of the
> buffer), just use memcpy() :-)
Yeah, I'd go this route. I find the fact that strncpy() does _not_
guarantee the null terminator to be kind of bizarre and unexpected.
--
Russell Bryant
Digium, Inc. | Senior Software Engineer, Open Source Team Lead
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: www.digium.com & www.asterisk.org
More information about the asterisk-dev
mailing list