DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] app/testpmd: add size check for flex item
@ 2026-09-07  3:50 kirankumark
  2026-09-07 18:24 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: kirankumark @ 2026-09-07  3:50 UTC (permalink / raw)
  To: Aman Singh; +Cc: dev, Kiran Kumar K

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] app/testpmd: add size check for flex item
  2026-09-07  3:50 [PATCH] app/testpmd: add size check for flex item kirankumark
@ 2026-09-07 18:24 ` Stephen Hemminger
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2026-09-07 18:24 UTC (permalink / raw)
  To: kirankumark; +Cc: Aman Singh, dev

On Mon, 7 Sep 2026 09:20:33 +0530
<kirankumark@marvell.com> wrote:

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

Applied to next-net.
Ended up rewriting commit message because this is fixing an observable bug.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-07 18:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-07  3:50 [PATCH] app/testpmd: add size check for flex item kirankumark
2026-09-07 18:24 ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox