app/testpmd: add boundary check in flow command
authorWei Zhao <wei.zhao1@intel.com>
Thu, 6 Dec 2018 02:38:06 +0000 (10:38 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 21 Dec 2018 15:22:41 +0000 (16:22 +0100)
There is need to add boundary for input number from commandline,
If it beyond the definition, code will return error.

Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
app/test-pmd/cmdline_flow.c

index 5c0108f..659908f 100644 (file)
@@ -4327,6 +4327,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):