On Wed, 20 Mar 2019 14:28:22 +0000
Ferruh Yigit <ferruh.yi...@intel.com> wrote:

> On 3/14/2019 4:20 PM, Stephen Hemminger wrote:
> > Do not allow creating a ethernet device with a name over the
> > allowed maximum (or zero length). This is safer than silently truncating
> > which is what happens now.
> > 
> > Signed-off-by: Stephen Hemminger <step...@networkplumber.org>
> > Acked-by: Andrew Rybchenko <arybche...@solarflare.com>
> > ---
> > v3 -- fix whitespace issue
> > 
> >  lib/librte_ethdev/rte_ethdev.c | 12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> > 
> > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
> > index 85c1794968dd..cf69daaf3224 100644
> > --- a/lib/librte_ethdev/rte_ethdev.c
> > +++ b/lib/librte_ethdev/rte_ethdev.c
> > @@ -438,6 +438,18 @@ rte_eth_dev_allocate(const char *name)
> >  {
> >     uint16_t port_id;
> >     struct rte_eth_dev *eth_dev = NULL;
> > +   size_t name_len;
> > +
> > +   name_len = strnlen(name, RTE_ETH_NAME_MAX_LEN);  
> 
> 'strlen' does not check against NULL pointer and it will crash if NULL 
> provided.
> 
> This is internal API, so the input is not completely out of our control but
> still as an API if we need to check zero length, shouldn't we check for NULL
> pointer as well?

Maybe, but none of the other DPDK API's check for NULL in name fields.
Probably best to just crash.

Reply via email to