Patchwork [dpdk-dev,v2] app/testpmd: add boundary check in flow commandline

login
register
mail settings
Submitter Wei Zhao
Date Dec. 6, 2018, 2:38 a.m.
Message ID <1544063886-68323-1-git-send-email-wei.zhao1@intel.com>
Download mbox | patch
Permalink /patch/673751/
State New
Headers show

Comments

Wei Zhao - Dec. 6, 2018, 2:38 a.m.
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>

---

v2:
change mask writing format.
---
 app/test-pmd/cmdline_flow.c | 2 ++
 1 file changed, 2 insertions(+)

Patch

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 23ea7cc..8b7a5c0 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -4325,6 +4325,8 @@  parse_int(struct context *ctx, const struct token *token,
 	}
 	buf = (uint8_t *)ctx->object + arg->offset;
 	size = arg->size;
+	if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
+		return -1;
 objmask:
 	switch (size) {
 	case sizeof(uint8_t):