DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] app/testpmd: add boundary check in flow commandline
@ 2018-12-04  5:51 Wei Zhao
  2018-12-04  7:46 ` Zhao1, Wei
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Wei Zhao @ 2018-12-04  5:51 UTC (permalink / raw)
  To: dev; +Cc: stable, yuan.peng, Wei Zhao

There is need to add boundary for input number from commandline,
If it beyond the defination, code will return error.

Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
---
 app/test-pmd/cmdline_flow.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 23ea7cc..515f95c 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -4325,6 +4325,25 @@ parse_int(struct context *ctx, const struct token *token,
 	}
 	buf = (uint8_t *)ctx->object + arg->offset;
 	size = arg->size;
+	switch (size) {
+	case sizeof(uint8_t):
+		if (u > 0xff)
+			return -1;
+	case sizeof(uint16_t):
+		if (u > 0xffff)
+			return -1;
+	case sizeof(uint8_t [3]):
+		if (u > 0xffffff)
+			return -1;
+	case sizeof(uint32_t):
+		if (u > 0xffffffff)
+			return -1;
+	case sizeof(uint64_t):
+		if (u > 0xffffffffffffffff)
+			return -1;
+	default:
+		break;
+	}
 objmask:
 	switch (size) {
 	case sizeof(uint8_t):
-- 
2.7.5

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

end of thread, other threads:[~2018-12-21 15:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-04  5:51 [dpdk-dev] [PATCH] app/testpmd: add boundary check in flow commandline Wei Zhao
2018-12-04  7:46 ` Zhao1, Wei
2018-12-04  9:22 ` Ananyev, Konstantin
2018-12-06  2:34   ` Zhao1, Wei
2018-12-06  2:38 ` [dpdk-dev] [PATCH v2] " Wei Zhao
2018-12-21 15:05   ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit

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