From 8109c2e94cebc3a148b97d6545a1019942354705 Mon Sep 17 00:00:00 2001 From: "yuhong.tao@intel.com" Date: Thu, 21 Mar 2019 22:04:37 +0800 Subject: [PATCH] DM: restrict vmname size to 32 bytes Length of vmname is restricted to MAX_VM_OS_NAME_LEN. Keep it coincide with VM name array size in vm_config. Tracked-On: #2851 Signed-off-by: Tao Yuhong Acked-by: Yin Fengwei Acked-by: Eddie Dong --- devicemodel/core/main.c | 4 ++++ devicemodel/hw/platform/ioc.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/devicemodel/core/main.c b/devicemodel/core/main.c index ec7d099e9..6e237f561 100644 --- a/devicemodel/core/main.c +++ b/devicemodel/core/main.c @@ -924,6 +924,10 @@ dm_run(int argc, char *argv[]) } vmname = argv[0]; + if (strnlen(vmname, MAX_VM_OS_NAME_LEN) >= MAX_VM_OS_NAME_LEN) { + fprintf(stderr, "vmname size exceed %u\n",MAX_VM_OS_NAME_LEN); + exit(1); + } for (;;) { ctx = vm_create(vmname, (unsigned long)vhm_req_buf); diff --git a/devicemodel/hw/platform/ioc.c b/devicemodel/hw/platform/ioc.c index 72aa17247..4f2e746f1 100644 --- a/devicemodel/hw/platform/ioc.c +++ b/devicemodel/hw/platform/ioc.c @@ -100,7 +100,7 @@ typedef void* (*ioc_work)(void *arg); * IOC mediator and virtual UART communication channel path, * comes from DM command line parameters. */ -static char virtual_uart_path[32]; +static char virtual_uart_path[32 + MAX_VM_OS_NAME_LEN]; /* * To activate CBC signal channel(/dev/cbc-signals).