From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8BAD4A0577 for ; Mon, 6 Apr 2020 17:20:25 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5032C2B83; Mon, 6 Apr 2020 17:20:25 +0200 (CEST) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by dpdk.org (Postfix) with ESMTP id 0D0B22B96 for ; Mon, 6 Apr 2020 17:20:24 +0200 (CEST) Received: by mail-pl1-f194.google.com with SMTP id d24so6030282pll.8 for ; Mon, 06 Apr 2020 08:20:23 -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=uab2ejFLhdc9Fi3LG4UW5jGTSEHW7GDPuZzA6om7l58=; b=ZaF7e/lLRl5Ee3ZgZmP0vo9EpFmNIJBQw5DQqxB1uTVYTuYauGjI54oJjTCS8MQ9jE KfH+f6GdSU3/SSH300Kxtf0fNCyiu6FMBszyaA1IcYcJ/3ADgenJqS3+7dbFVOlDbZtg nq+4myw/nk4N8D6LHrIaNUVSrmBY9bCh72zp4NvHF18FQzIRmCcW4/swMMjAidzD5flR Sfo18G1JmTy4Gh84TU31qn8P/GQYlmVCchVn50pFh0Rz44FiIY4bqoUdxwsFL6gYbZLI 27xtZBINbtOQNi5cjogOn+F4Ko9BbHs1UUE0O5Hq+gQxTcowmCkNkt1UJ857rFp0XxWN HZPg== 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=uab2ejFLhdc9Fi3LG4UW5jGTSEHW7GDPuZzA6om7l58=; b=quKSSOkaK9Z5jrEhuyxh1iwpeXjo2dWxReWhx7mHDT77lpgY4seQ9GswRvLI7fERom WDXJtAnQFjmSGvJj4XFWQ6MKYP1+GfOL6dOuiH7Ym6VpV0p2FAgUZaVVeodTJbC5zPe8 Ald3Ffj5BBppCpnlenhgpLPLKOFLf7LD1yAvcSSa4SolHlkRqXVtoMs/4mZygjTgZ+qj hKoW+7G/N9iUKCeRMQmdcVOn6fVI2i6EYUFC0QnElR9utgDT3Kp1nXKQ7Y4R70KvT96E lZ0TRaVZrg9ZspwxIVLCjCvuijC9l/Md9tFB5+p9Yyhf98ETtEtxYNa3o4zJGFLMkgIK hYyA== X-Gm-Message-State: AGi0PuZvAGXXRXBX4FDL0e29vtlWVkAHnOHcG8tdvuO0Rim+IwI11lZa KMuHRI6HugdY7grw+I0b/sJJ4w== X-Google-Smtp-Source: APiQypJ1/5r1vY3sC95vVIbJRw4G3o/I4yAV8dY6CXrisB+063lRETfn/fuxSSwW9WBezn/yycVnSw== X-Received: by 2002:a17:90b:1b01:: with SMTP id nu1mr26374923pjb.129.1586186423064; Mon, 06 Apr 2020 08:20:23 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id h15sm11868996pfq.10.2020.04.06.08.20.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 08:20:22 -0700 (PDT) Date: Mon, 6 Apr 2020 08:20:14 -0700 From: Stephen Hemminger To: Muhammad Bilal Cc: hemant.agrawal@nxp.com, olivier.matz@6wind.com, dev@dpdk.org, stable@dpdk.org Message-ID: <20200406082014.0c46bd90@hermes.lan> In-Reply-To: <20200406113020.8074-1-m.bilal@emumba.com> References: <20200406113020.8074-1-m.bilal@emumba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH] putting null checks on ops_name X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" On Mon, 6 Apr 2020 16:30:20 +0500 Muhammad Bilal wrote: > Bugzilla ID: 353 > Cc: dev@dpdk.org > Cc: stable@dpdk.org > Cc: hemant.agrawal@nxp.com > Signed-off-by: Muhammad Bilal > --- > lib/librte_mbuf/rte_mbuf_pool_ops.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/lib/librte_mbuf/rte_mbuf_pool_ops.c b/lib/librte_mbuf/rte_mbuf_pool_ops.c > index 5722976fe..c3ddfc0bd 100644 > --- a/lib/librte_mbuf/rte_mbuf_pool_ops.c > +++ b/lib/librte_mbuf/rte_mbuf_pool_ops.c > @@ -13,7 +13,8 @@ int > rte_mbuf_set_platform_mempool_ops(const char *ops_name) > { > const struct rte_memzone *mz; > - > + if (strlen(ops_name) == 0) > + return -1; > if (strlen(ops_name) >= RTE_MEMPOOL_OPS_NAMESIZE) > return -ENAMETOOLONG; > > @@ -50,7 +51,8 @@ int > rte_mbuf_set_user_mempool_ops(const char *ops_name) > { > const struct rte_memzone *mz; > - > + if (strlen(ops_name) == 0) > + return -1; > if (strlen(ops_name) >= RTE_MEMPOOL_OPS_NAMESIZE) > return -ENAMETOOLONG; > If you want to do it simpler and safer use strnlen. Also, don't mix -1 wit -errno returns. size_t len = strnlen(ops_name, RTE_MEMPOOL_OPS_NAMESIZE); if (len == 0) return -EINVAL; if (len == RTE_MEMPOOL_OPS_NAMESIZE) return -ENAMETOOLONG;