diff --git a/tools/acrn-manager/acrn_mngr.h b/tools/acrn-manager/acrn_mngr.h index 7aafec0a4..d0539c7c0 100644 --- a/tools/acrn-manager/acrn_mngr.h +++ b/tools/acrn-manager/acrn_mngr.h @@ -7,9 +7,9 @@ #define ACRN_MANAGER_H #include +#include #define MNGR_MSG_MAGIC 0x67736d206d6d76 /* that is char[8] "mngr msg", on X86 */ -#define VMNAME_LEN 16 struct mngr_msg { unsigned long long magic; /* Make sure you get a mngr_msg */ @@ -28,7 +28,7 @@ struct mngr_msg { /* req of ACRND_TIMER */ struct req_acrnd_timer { - char name[VMNAME_LEN]; + char name[MAX_VM_OS_NAME_LEN]; time_t t; } acrnd_timer; @@ -52,7 +52,7 @@ struct mngr_msg { /* req of RTC_TIMER */ struct req_rtc_timer { - char vmname[VMNAME_LEN]; + char vmname[MAX_VM_OS_NAME_LEN]; time_t t; } rtc_timer; diff --git a/tools/acrn-manager/acrnctl.c b/tools/acrn-manager/acrnctl.c index 519c7c8e9..fae9749a3 100644 --- a/tools/acrn-manager/acrnctl.c +++ b/tools/acrn-manager/acrnctl.c @@ -85,6 +85,11 @@ static int check_name(const char *name) if (!strcmp(name, "nothing")) return -1; + if (strnlen(name, MAX_VM_OS_NAME_LEN) >= MAX_VM_OS_NAME_LEN) { + printf("(%s) size exceed MAX_VM_OS_NAME_LEN:%u\n", name,MAX_VM_OS_NAME_LEN); + return -1; + } + return 0; } diff --git a/tools/acrn-manager/acrnctl.h b/tools/acrn-manager/acrnctl.h index 59547b646..bf9591caa 100644 --- a/tools/acrn-manager/acrnctl.h +++ b/tools/acrn-manager/acrnctl.h @@ -7,6 +7,8 @@ #define _ACRNCTL_H_ #include +#include +#include "acrn_mngr.h" #define ACRN_CONF_PATH "/usr/share/acrn/conf" #define ACRN_CONF_PATH_ADD ACRN_CONF_PATH "/add" @@ -14,8 +16,6 @@ #define ACRN_DM_SOCK_PATH "/run/acrn/mngr" -#define MAX_NAME_LEN (32) - enum vm_state { VM_STATE_UNKNOWN = 0, VM_CREATED, /* VM created / awaiting start (boot) */ @@ -36,7 +36,7 @@ struct vmmngr_struct *vmmngr_find(const char *vmname); /* Per-vm vm managerment struct */ struct vmmngr_struct { - char name[MAX_NAME_LEN]; + char name[MAX_VM_OS_NAME_LEN]; unsigned long state; unsigned long state_tmp; unsigned long update; /* update count, remove a vm if no update for it */ diff --git a/tools/acrn-manager/acrnd.c b/tools/acrn-manager/acrnd.c index 626d84c12..75bd378b7 100644 --- a/tools/acrn-manager/acrnd.c +++ b/tools/acrn-manager/acrnd.c @@ -23,7 +23,7 @@ /* acrnd worker timer */ struct work_arg { - char name[VMNAME_LEN]; + char name[MAX_VM_OS_NAME_LEN]; }; struct acrnd_work { @@ -356,7 +356,7 @@ static void handle_timer_req(struct mngr_msg *msg, int client_fd, void *param) } strncpy(arg.name, msg->data.acrnd_timer.name, sizeof(arg.name) - 1); - if (sizeof(arg.name) - 1 < strnlen(msg->data.acrnd_timer.name, VMNAME_LEN)) { + if (sizeof(arg.name) - 1 < strnlen(msg->data.acrnd_timer.name, MAX_VM_OS_NAME_LEN)) { perror("timer name was truncated\n"); goto reply_ack; }