[asterisk-dev] seanbright: tools/trunk r5656 - /tools/trunk/dahdi_monitor.c

Sean Bright sean.bright at gmail.com
Tue Jan 13 22:40:42 CST 2009


Russell Bryant wrote:
> On Jan 13, 2009, at 5:46 PM, SVN commits to the Digium repositories  
> wrote:
>> -	dahdi_copy_string(bar+(barlen/2), "(TX)", 4);
>> +	strncpy(bar + (barlen / 2), "(TX)", 4);
> 
> 
> Alternatively, when copying a constant string into a buffer that you  
> _know_ is big enough, you can just use strcpy().

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.

-- 
Sean Bright
sean.bright at gmail.com



More information about the asterisk-dev mailing list