All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mahmoud Maatuq <mahmoudmatook.mm@gmail.com>
To: Sunil Kumar Kori <skori@marvell.com>,
	Rakesh Kudurumalla <rkudurumalla@marvell.com>,
	Nithin Dabilpuram <ndabilpuram@marvell.com>,
	Jerin Jacob <jerinj@marvell.com>
Cc: dev@dpdk.org, Mahmoud Maatuq <mahmoudmatook.mm@gmail.com>
Subject: [PATCH v2] app/graph: fix destination buffer too small
Date: Tue, 25 Jun 2024 00:01:14 +0400	[thread overview]
Message-ID: <20240624200114.1792214-1-mahmoudmatook.mm@gmail.com> (raw)
In-Reply-To: <20240623200921.1715890-1-mahmoudmatook.mm@gmail.com>

as sizeof(config.rx.mempool_name) is < sizeof(res->mempool) we should
copy at most sizeof(config.rx.mempool_name) and replace memcpy with
strlcpy as mempool name is a null terminated string

Coverity issue: 415430
Fixes: 3850cb06ab9c ("app/graph: add ethdev commands")
Cc: skori@marvell.com

Signed-off-by: Mahmoud Maatuq <mahmoudmatook.mm@gmail.com>
---
v2:
* replaced memcpy with strlcpy
---
 app/graph/ethdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/app/graph/ethdev.c b/app/graph/ethdev.c
index cfc1b18569..e7a02b40a9 100644
--- a/app/graph/ethdev.c
+++ b/app/graph/ethdev.c
@@ -16,6 +16,7 @@

 #include "ethdev_priv.h"
 #include "module_api.h"
+#include "rte_string_fns.h"

 static const char
 cmd_ethdev_mtu_help[] = "ethdev <ethdev_name> mtu <mtu_sz>";
@@ -671,7 +672,7 @@ cmd_ethdev_parsed(void *parsed_result, __rte_unused struct cmdline *cl, void *da
 	memset(&config, 0, sizeof(struct ethdev_config));
 	config.rx.n_queues = res->nb_rxq;
 	config.rx.queue_size = ETHDEV_RX_DESC_DEFAULT;
-	memcpy(config.rx.mempool_name, res->mempool, strlen(res->mempool));
+	strlcpy(config.rx.mempool_name, res->mempool, sizeof(config.rx.mempool_name));

 	config.tx.n_queues = res->nb_txq;
 	config.tx.queue_size = ETHDEV_TX_DESC_DEFAULT;
--
2.43.0


  parent reply	other threads:[~2024-06-24 20:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-23 20:09 [PATCH] app/graph: fix destination buffer too small Mahmoud Maatuq
2024-06-23 20:26 ` Stephen Hemminger
2024-06-26 20:22   ` Mahmoud Matook
2024-06-24 20:01 ` Mahmoud Maatuq [this message]
2024-06-25  4:41   ` [EXTERNAL] [PATCH v2] " Kiran Kumar Kokkilagadda
2024-06-26 20:18     ` Mahmoud Matook
2024-06-27  0:43       ` Kiran Kumar Kokkilagadda
2024-07-04 15:17         ` David Marchand
2024-07-06 14:08           ` Mahmoud Matook

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=20240624200114.1792214-1-mahmoudmatook.mm@gmail.com \
    --to=mahmoudmatook.mm@gmail.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=ndabilpuram@marvell.com \
    --cc=rkudurumalla@marvell.com \
    --cc=skori@marvell.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.