From 2b7126f5fce80014853a086e12b83b78b6bca6fe Mon Sep 17 00:00:00 2001 From: Cheng Jiang Date: Fri, 6 Nov 2020 03:24:01 +0000 Subject: [PATCH] examples/vhost: check argument length Add args length check before copying to fix the coverity issue. Coverity issue: 363741 Fixes: 3a04ecb21420 ("examples/vhost: add async vhost args parsing") Signed-off-by: Cheng Jiang Reviewed-by: Maxime Coquelin --- examples/vhost/main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/vhost/main.c b/examples/vhost/main.c index 59a1aff07c..ec88874d16 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -634,6 +634,12 @@ us_vhost_parse_args(int argc, char **argv) if (!strncmp(long_option[option_index].name, "dma-type", MAX_LONG_OPT_SZ)) { + 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); } -- 2.20.1