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 DBFD9A0577; Mon, 6 Apr 2020 17:20:26 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7F30E1BED7; Mon, 6 Apr 2020 17:20:25 +0200 (CEST) Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by dpdk.org (Postfix) with ESMTP id 0241E2B83 for ; Mon, 6 Apr 2020 17:20:23 +0200 (CEST) Received: by mail-pj1-f68.google.com with SMTP id kx8so6597888pjb.5 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=Z51QnovVDwjXj8vda8d7SP/4c4a0XcSN3CaQtKdBsA2TSQU2IZ42gv2ERv3+mx4hgZ o0JrVM3Z1sxjR+rjtUnpQj4aLzDPw9UmvbWH56wKQR8MpudIagNOK/14vXyhuJm/8Fvt qWZLY8L/gjk/HusQYp9jGlmEgUy3lPfWyLa/nroRcNbspRWV8zNjQzvyafeO+/mPAPTH ns+yYOfEtEyi81MSR6YqLpkd0EU+kxScH5t/oTTxlAMQCf3SJVNUY4i55KX7/VBz1mJc uFUJxXIvpwUFF3KnAulU9/Eo/UJkqYcc6BtcU+pS2SlDwSmFFtxW07bXk+5swleW8Zjc /Dfw== X-Gm-Message-State: AGi0PuaU6tT3i2mnCLOxJP/vmUmTr1lZy2MKuwzS1v8c30olKzGN5+nA Ga4hWE6js4TlO9UT76onbr8IeQ== 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-dev] [PATCH] putting null checks on ops_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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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;