[v2] putting null checks on ops_name

Message ID 20200407075613.29273-1-m.bilal@emumba.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v2] putting null checks on ops_name |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed

Commit Message

Muhammad Bilal April 7, 2020, 7:56 a.m. UTC
  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(-)
  

Comments

Hemant Agrawal April 7, 2020, 10:16 a.m. UTC | #1
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
  
Thomas Monjalon April 25, 2020, 8:59 p.m. UTC | #2
07/04/2020 09:56, Muhammad Bilal:
> 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>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>

No need to Cc stable in my opinion, as there is no bug fixed.

Changing the name to:
	mbuf: prevent setting mempool ops name empty

Applied with below minor change, thanks


The blank line below should remain:

>  	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;
  

Patch

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");