DPDK patches and discussions
 help / color / mirror / Atom feed
From: Muhammad Bilal <m.bilal@emumba.com>
To: hemant.agrawal@nxp.com, olivier.matz@6wind.com,
	stephen@networkplumber.org
Cc: dev@dpdk.org, Muhammad Bilal <m.bilal@emumba.com>, stable@dpdk.org
Subject: [dpdk-dev] [PATCH v2] putting null checks on ops_name
Date: Tue,  7 Apr 2020 12:56:13 +0500	[thread overview]
Message-ID: <20200407075613.29273-1-m.bilal@emumba.com> (raw)
In-Reply-To: <20200406113020.8074-1-m.bilal@emumba.com>

Bugzilla ID: 353
Cc: dev@dpdk.org
Cc: stable@dpdk.org
Cc: hemant.agrawal@nxp.com
Signed-off-by: Muhammad Bilal <m.bilal@emumba.com>
---
 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


  parent reply	other threads:[~2020-04-07  7:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-06 11:30 [dpdk-dev] [PATCH] " Muhammad Bilal
2020-04-06 15:20 ` Stephen Hemminger
2020-04-07  7:56 ` Muhammad Bilal [this message]
2020-04-07 10:16   ` [dpdk-dev] [PATCH v2] " Hemant Agrawal
2020-04-25 20:59   ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200407075613.29273-1-m.bilal@emumba.com \
    --to=m.bilal@emumba.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=olivier.matz@6wind.com \
    --cc=stable@dpdk.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).