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 740B9A0577; Tue, 7 Apr 2020 09:56:54 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5F6032BE2; Tue, 7 Apr 2020 09:56:53 +0200 (CEST) Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by dpdk.org (Postfix) with ESMTP id D86012B83 for ; Tue, 7 Apr 2020 09:56:51 +0200 (CEST) Received: by mail-lf1-f68.google.com with SMTP id j17so1602955lfe.7 for ; Tue, 07 Apr 2020 00:56:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emumba-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=t6BUceYtbJnzsRoMKhdU2tXDuQcuNWZq64zD40p3hb0=; b=x00+abWsmDWxuEWx1KxQx3ybfq42LeZe1EZ5aGowN9YtEKg5mjiJbjvF+/NwXXTllD 8pJwIAItw3IF/aQjB7Us3In5nibjRjjU67HSG45wWaRQqdXXHvdVdPxpKpRwbf07C8f4 cleCw7rfgzR81i/ideg1my41x4lyRcQyuOtjram6CaK9A291CtfTWHf0p5+fNbZxjOhv B44exjShGS5GrCkBuqYtfINzghJSndIpSzcyb6Sgt3xb/GCgniC7Z6CcLpzR35QpWMOa ohXbrfmTm/RdRg3Hpc6hubmwqD7Uyfh86Txy4kWBIivLJflXsch7njGXGmb4sHcNIUD8 tzkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=t6BUceYtbJnzsRoMKhdU2tXDuQcuNWZq64zD40p3hb0=; b=cBTRbERsoMIz7LF1wNgzB/h40kVHUolT5sAfGe3oOR0KY9xpixUP4+Ll1WwvWe3JcK BAdpv9rxmC8tGxW1YHG0P4k7yHLYUVZlB/XtBnG3Gp9A6XU9iN7YrLUqW4IZwkTIFa9Y Ke278tIY/qmjO5Jxm1KEBGv8uyad61AzNCux4VRFtl+1LkTB7MZRN/B+/C90iQ7b0aGq r9484/e7yD+5FpF41TjSJwsMp4VOA9omUrLtyjttZ2fFMae9YTP3H5WdxBHrnnPGk2bs qvAA0MTDy9lnPsgHuZMMZ/du19XeB6oMHw4txJP94cfMaDokDtrf3GGPIq9aL1JBChkO DiBg== X-Gm-Message-State: AGi0PuaBxTyLHQgF/0BeY8cjlgjm85sHrvjltBH5aTtCJafRIStIyQuR bVNIK1kswwalgJHNny3fufePnA== X-Google-Smtp-Source: APiQypI+aIFVuyc5GAIk7Bxg0Pb6ZOXfi1Toik+dRlmSbw8FyDNPsBxZjDgR0970AEpyiUZJSvn7RQ== X-Received: by 2002:a19:501a:: with SMTP id e26mr717343lfb.93.1586246211346; Tue, 07 Apr 2020 00:56:51 -0700 (PDT) Received: from localhost.localdomain ([111.119.188.2]) by smtp.gmail.com with ESMTPSA id o16sm11754482ljp.53.2020.04.07.00.56.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 00:56:50 -0700 (PDT) From: Muhammad Bilal To: hemant.agrawal@nxp.com, olivier.matz@6wind.com, stephen@networkplumber.org Cc: dev@dpdk.org, Muhammad Bilal , stable@dpdk.org Date: Tue, 7 Apr 2020 12:56:13 +0500 Message-Id: <20200407075613.29273-1-m.bilal@emumba.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200406113020.8074-1-m.bilal@emumba.com> References: <20200406113020.8074-1-m.bilal@emumba.com> Subject: [dpdk-dev] [PATCH v2] 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" 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 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf_pool_ops.c b/lib/librte_mbuf/rte_mbuf_pool_ops.c index 5722976fe..00186aa15 100644 --- a/lib/librte_mbuf/rte_mbuf_pool_ops.c +++ b/lib/librte_mbuf/rte_mbuf_pool_ops.c @@ -13,8 +13,10 @@ int rte_mbuf_set_platform_mempool_ops(const char *ops_name) { const struct rte_memzone *mz; - - if (strlen(ops_name) >= RTE_MEMPOOL_OPS_NAMESIZE) + size_t len = strnlen(ops_name, RTE_MEMPOOL_OPS_NAMESIZE); + if (len == 0) + return -EINVAL; + if (len == RTE_MEMPOOL_OPS_NAMESIZE) return -ENAMETOOLONG; mz = rte_memzone_lookup("mbuf_platform_pool_ops"); @@ -50,8 +52,10 @@ int rte_mbuf_set_user_mempool_ops(const char *ops_name) { const struct rte_memzone *mz; - - if (strlen(ops_name) >= RTE_MEMPOOL_OPS_NAMESIZE) + size_t len = strnlen(ops_name, RTE_MEMPOOL_OPS_NAMESIZE); + if (len == 0) + return -EINVAL; + if (len == RTE_MEMPOOL_OPS_NAMESIZE) return -ENAMETOOLONG; mz = rte_memzone_lookup("mbuf_user_pool_ops"); -- 2.17.1