[dpdk-dev] [RFC v2] /net: memory interface (memif)

Burakov, Anatoly anatoly.burakov at intel.com
Wed Dec 12 11:19:02 CET 2018


On 10-Dec-18 10:50 AM, Richardson, Bruce wrote:
> 
> 
>> -----Original Message-----
>> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Burakov, Anatoly
>> Sent: Monday, December 10, 2018 10:43 AM
>> To: Jakub Grajciar <jgrajcia at cisco.com>; dev at dpdk.org
>> Subject: Re: [dpdk-dev] [RFC v2] /net: memory interface (memif)
>>
>> On 10-Dec-18 10:06 AM, Jakub Grajciar wrote:
>>> Signed-off-by: Jakub Grajciar <jgrajcia at cisco.com>
>>> ---
>>
>> As a general comment, some description/cover letter would have been nice.
>>
>>> +
>>> +	memif_msg_disconnect_t *d = &e->msg.disconnect;
>>> +
>>> +	e->msg.type = MEMIF_MSG_TYPE_DISCONNECT;
>>> +	d->code = err_code;
>>> +
>>> +	if (reason != NULL) {
>>> +		strncpy((char *)d->string, reason, strlen(reason));
>>> +		if (cc->pmd != NULL) {
>>> +			strncpy(cc->pmd->local_disc_string, reason,
>>> +				strlen(reason));
>>> +		}
>>
>> I haven't looked at the entire thing, this is just something that caught
>> my eye during quick skimming through code.
>>
>> On the face of it, this looks dangerous - you're setting the destination
>> buffer size from source buffer size. What if `d->string` is shorter than
>> `reason`?
>>
> 
> And strncpy is dangerous - use strlcpy instead.

Isn't strscpy the string copy function du jour now? :)

> 
> /Bruce
> 


-- 
Thanks,
Anatoly


More information about the dev mailing list