[v2] app/testpmd: add boundary check in flow commandline

Message ID 1544063886-68323-1-git-send-email-wei.zhao1@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v2] app/testpmd: add boundary check in flow commandline |

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS

Commit Message

Zhao1, Wei Dec. 6, 2018, 2:38 a.m. UTC
  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(+)
  

Comments

Ferruh Yigit Dec. 21, 2018, 3:05 p.m. UTC | #1
On 12/6/2018 2:38 AM, Wei Zhao wrote:
> 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>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/master, thanks.
  

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