[Cbe-oss-dev] [PATCH 10/10] MARS: workload type move from context to queue block

Yuji Mano Yuji.Mano at am.sony.com
Thu Aug 7 04:42:42 EST 2008


Geert Uytterhoeven wrote:
> On Tue, 5 Aug 2008, Geoff Levand wrote:
>> Yuji Mano wrote:
>> >  	/* copy the task name into task id */
>> >  	if (params->name) {
>> >  		MARS_CHECK_RET(strlen(params->name) < MARS_TASK_NAME_LEN_MAX,
>> >  				MARS_ERROR_PARAMS);
>> > -		strcpy((char *)&task->id.name, params->name);
>> > +		strcpy((char *)&task.id.name, params->name);
>> 
>> What if params->name is too big, should this be strncpy?
> 
> Or strlcpy(), as strncpy() is not guaranteed to zero-terminate the destination
> buffer?

I do a check right before the strcpy() so that it returns MARS_ERROR_PARAMS if
the src string is too long to fit in the dst buffer. 'task.id.name' is a buffer
of size MARS_TASK_NAME_LEN_MAX.

Regards,
Yuji




More information about the cbe-oss-dev mailing list