Add args length check to fix potential overflow issue.
Coverity issue: 363741
Fixes: 965b06f0358 ("examples/vhost: enhance getopt_long usage")
Cc: [email protected]
Signed-off-by: Cheng Jiang <[email protected]>
---
examples/vhost/main.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 119ba7e01..5df36ad3c 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -669,6 +669,11 @@ us_vhost_parse_args(int argc, char **argv)
break;
case OPT_DMA_TYPE_NUM:
+ if (strlen(optarg) >= MAX_LONG_OPT_SZ) {
+ RTE_LOG(INFO, VHOST_CONFIG, "Wrong DMA type\n");
+ us_vhost_usage(prgname);
+ return -1;
+ }
strcpy(dma_type, optarg);
break;
--
2.29.2