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 <yuhong.tao@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
yuhong.tao@intel.com 2019-03-21 22:04:37 +08:00 committed by wenlingz
parent b1586ccc3e
commit 8109c2e94c
2 changed files with 5 additions and 1 deletions

View File

@ -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);

View File

@ -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).