[dpdk-dev] [PATCH 3/3] app/pdump: fix string overflow

Pattan, Reshma reshma.pattan at intel.com
Wed Jun 22 11:24:34 CEST 2016


Hi,

> -----Original Message-----
> From: Richardson, Bruce
> Sent: Wednesday, June 22, 2016 10:22 AM
> To: Anupam Kapoor <anupam.kapoor at gmail.com>
> Cc: Yigit, Ferruh <ferruh.yigit at intel.com>; Pattan, Reshma
> <reshma.pattan at intel.com>; dev at dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 3/3] app/pdump: fix string overflow
> 
> On Wed, Jun 22, 2016 at 12:16:27PM +0530, Anupam Kapoor wrote:
> > >       if (!strcmp(key, PDUMP_RX_DEV_ARG)) {
> > > -             strncpy(pt->rx_dev, value, strlen(value));
> > > +             strncpy(pt->rx_dev, value, sizeof(pt->rx_dev)-1);
> >
> > I guess size-1 is to give room for terminating null byte, but for this
> > case is it guarantied that pt->rx_dev last byte is NULL?
> >
> > why not just use a snprintf(...) here since it has better error behavior ?
> > although compared to str*cpy it might be a bit slow, but hopefully
> > that should be ok ?
> >
> 
> Definite +1. For safely copying strings I think snprintf is often the easiest API to
> use.
> 

Ok, will make the changes.

Thanks,
Reshma


More information about the dev mailing list