DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: <kirankumark@marvell.com>
To: Aman Singh <aman.deep.singh@intel.com>
Cc: <dev@dpdk.org>, Kiran Kumar K <kirankumark@marvell.com>
Subject: [PATCH] app/testpmd: add size check for flex item
Date: Mon, 7 Sep 2026 09:20:33 +0530	[thread overview]
Message-ID: <20260907035033.800034-1-kirankumark@marvell.com> (raw)

From: Kiran Kumar K <kirankumark@marvell.com>

Adding changes for size check for flex item in testpmd.

Signed-off-by: Kiran Kumar K <kirankumark@marvell.com>
---
 app/test-pmd/cmd_flex_item.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/app/test-pmd/cmd_flex_item.c b/app/test-pmd/cmd_flex_item.c
index af6c087feb..c0bbff7b45 100644
--- a/app/test-pmd/cmd_flex_item.c
+++ b/app/test-pmd/cmd_flex_item.c
@@ -231,6 +231,12 @@ static int flex_item_config(json_t *jroot,
 		} else if (match_strkey(key, "sample_data")) {
 			json_t *ji;
 			uint32_t i, size = json_array_size(jobj);
+			if (size > FLEX_ITEM_MAX_SAMPLES_NUM) {
+				printf("Number of sample_data entries (%u) exceeds maximum %u\n",
+				       size, FLEX_ITEM_MAX_SAMPLES_NUM);
+				ret = -EINVAL;
+				goto out;
+			}
 			for (i = 0; i < size; i++) {
 				ji = json_array_get(jobj, i);
 				ret = flex_field_parse
@@ -244,6 +250,12 @@ static int flex_item_config(json_t *jroot,
 		} else if (match_strkey(key, "input_link")) {
 			json_t *ji;
 			uint32_t i, size = json_array_size(jobj);
+			if (size > FLEX_ITEM_MAX_LINKS_NUM) {
+				printf("Number of input_link entries (%u) exceeds maximum %u\n",
+				       size, FLEX_ITEM_MAX_LINKS_NUM);
+				ret = -EINVAL;
+				goto out;
+			}
 			for (i = 0; i < size; i++) {
 				ji = json_array_get(jobj, i);
 				ret = flex_link_parse(ji,
@@ -258,6 +270,12 @@ static int flex_item_config(json_t *jroot,
 		} else if (match_strkey(key, "output_link")) {
 			json_t *ji;
 			uint32_t i, size = json_array_size(jobj);
+			if (size > FLEX_ITEM_MAX_LINKS_NUM) {
+				printf("Number of output_link entries (%u) exceeds maximum %u\n",
+				       size, FLEX_ITEM_MAX_LINKS_NUM);
+				ret = -EINVAL;
+				goto out;
+			}
 			for (i = 0; i < size; i++) {
 				ji = json_array_get(jobj, i);
 				ret = flex_link_parse
-- 
2.50.1


             reply	other threads:[~2026-09-07  3:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-07  3:50 kirankumark [this message]
2026-09-07 18:24 ` [PATCH] app/testpmd: add size check for flex item Stephen Hemminger

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=20260907035033.800034-1-kirankumark@marvell.com \
    --to=kirankumark@marvell.com \
    --cc=aman.deep.singh@intel.com \
    --cc=dev@dpdk.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