On Wed, Dec 12, 2018 at 10:19:02AM +0000, Burakov, Anatoly wrote:
> On 10-Dec-18 10:50 AM, Richardson, Bruce wrote:
> > 
> > 
> > > -----Original Message-----
> > > From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Burakov, Anatoly
> > > Sent: Monday, December 10, 2018 10:43 AM
> > > To: Jakub Grajciar <jgraj...@cisco.com>; dev@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 <jgraj...@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? :)
> 
Well, it's certainly the new one! It's only available as a DPDK-specific
function though - "rte_strscpy". Therefore, I think strlcpy is generally
preferred, but either will do.

/Bruce

Reply via email to