Subject: Re: [KJ] [tipc-discussion] [patch] net/tipc: sprintf/strcpy conversion

From: walter harms <[email-masked]>
Date: Thu, 02 Nov 2006 08:57:55 +0100

Florian Westphal wrote:
> walter harms <[email-masked]> wrote:
>> These line
>> +       strcpy(bcbearer->media.name, "tipc-multicast");
>> i gues that means tipc_bclink_name ?
> 
> The idea was to change how things are done, not _what_ is being done.
> 
>> an even more secure version could be like this:
>>
>> 	strncpy(bcbearer->media.name,sizeof(bcbearer->media.name),tipc_bclink_name);
> 
> Ugh, please, no. The size of src is known in all cases; there is
> absoluty no point in using str(n|l)cpy here.
> 
>> (in case someone ever changes the size of cbearer->media.name or tipc_bclink_name and the hope
>> that wchat_t will never reach the kernel)
> 
> In this case 'someone' should be really hurt, don't you think?
> 

hi florian,
i am on the side of error, the code increase is marginal and the speed penalty also, so why not ?
you make sure that an overflow may never happen, and the rest in name gets zeroed.

The problem is that when the error occurs it may be later than the actual changeset.
NTL it is an hint, and if you feel ok with it and the maintainer has no objects i have no problems either.

re,
 wh