From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by dpdk.org (Postfix) with ESMTP id 33B8B3572 for ; Wed, 13 Mar 2019 18:32:38 +0100 (CET) Received: by mail-pg1-f196.google.com with SMTP id m2so2013074pgl.5 for ; Wed, 13 Mar 2019 10:32:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xhlBRvZ8w8qh9V620ZcxmBeBL4fBZpJofsm6s4tjTSw=; b=vE9wG9B1GzR+4thTbUuEdbu5PLXDOTKlUTNxjYkTHiklamRH8gfVUloTRjb/b/4LgI z9LxkGF65zK4ZWwVL1mf3s+JONcfDMICSzqas3RcYC/J6ssvaOhfH4tagTtr6Uw2vSMx dIfvi9ehaLxNzUQODtsw8pdEiJfY/Ouj5aEWgZ6rbxVjhmdeDzQQOkvmqqS9veVcqUne YIc9Fi69QmMU5rfpxzXWkgKnQFhbrMnqE1TQqXEBUutBJXQCUFVBrJex7iX1IJNyHBGx 9XhwPvKkEJ//qiMO6WymoZh5L7UYRk9HkmGtbOtgyASO3z6S4g2e/GRDyPGa9ADucc7u ZIAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xhlBRvZ8w8qh9V620ZcxmBeBL4fBZpJofsm6s4tjTSw=; b=baXgE6sBKIAiftFtKl54i9YWLhyOEc0HZRDON7Y9RjE8y1wLMie7YQRJK2Xv5HpkFn t3/xF4eVO79bB462MvdsvIUtcBWJgP1t/IZXQcZxVtdugxH7TwZWOLVX33sifeIqUxk7 zUft191Z9IYpVNQ8ai9P2kPgHLviVZS/AOC9Tfodsl4eYKrEHX6XFmLJEPPl51Nvvf9H +IXuQ929R9ORLQPMlNem/jWr9bUt7qSrbd19xnMF69ngL5mYED0JDFk3URP2y4h6bNRb j4pL3WFHjrfV000TXl2ehA7RTyDl0fHsIHll3uTm3jmDMWRlKugj1WENor3RIjlZVa3Z snsQ== X-Gm-Message-State: APjAAAUUchSsBOdkvas5Q8Tbn9jcLT2aLV+TWtqG343V1OX6eKkpVLFv XLtAoCLIjrdddzpDILdBRy2pag== X-Google-Smtp-Source: APXvYqyMUnjfd8VLxa1R1HvdbeG0enlPZ1hzPp8uIZ072YsIpc6XWJH/zQcO3nwild9B4QjOrQr23g== X-Received: by 2002:a17:902:a414:: with SMTP id p20mr45801081plq.289.1552498357238; Wed, 13 Mar 2019 10:32:37 -0700 (PDT) Received: from shemminger-XPS-13-9360 (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id o2sm28209172pfa.76.2019.03.13.10.32.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Mar 2019 10:32:36 -0700 (PDT) Date: Wed, 13 Mar 2019 10:32:32 -0700 From: Stephen Hemminger To: "Zhang, Qi Z" Cc: "dev@dpdk.org" Message-ID: <20190313103232.35804089@shemminger-XPS-13-9360> In-Reply-To: <039ED4275CED7440929022BC67E706115334BE52@SHSMSX103.ccr.corp.intel.com> References: <20190311181544.15646-1-stephen@networkplumber.org> <039ED4275CED7440929022BC67E706115334BE52@SHSMSX103.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] ethdev: check for invalid device name X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Mar 2019 17:32:38 -0000 On Wed, 13 Mar 2019 12:52:50 +0000 "Zhang, Qi Z" wrote: > HI > > > -----Original Message----- > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Stephen Hemminger > > Sent: Tuesday, March 12, 2019 2:16 AM > > To: dev@dpdk.org > > Cc: Stephen Hemminger > > Subject: [dpdk-dev] [PATCH] ethdev: check for invalid device name > > > > 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 > > Acked-by: Andrew Rybchenko > > --- > > v1 - previously sent as RFC > > > > lib/librte_ethdev/rte_ethdev.c | 10 ++++++++++ > > 1 file changed, 10 insertions(+) > > > > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c > > index 85c1794968dd..0b81980ff71c 100644 > > --- a/lib/librte_ethdev/rte_ethdev.c > > +++ b/lib/librte_ethdev/rte_ethdev.c > > @@ -439,6 +439,16 @@ rte_eth_dev_allocate(const char *name) > > uint16_t port_id; > > struct rte_eth_dev *eth_dev = NULL; > > > > + if (*name) { > > Is above check same as "strlen(name) == 0"? Yes, but checking for first null byte is slightly quicker. Alternative would be to call strnlen() once.