tools: acrn-crashlog: fix potential issues

Changes include:
1. check the parameter of snprintf
2. remove atoi
3. remove sscanf
4. fix one memleak

Tracked-On: #1024
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Huang, Yonghua <yonghua.huang@intel.com>
Acked-by: Chen, Gang <gang.c.chen@intel.com>
This commit is contained in:
Liu, Xinwu
2018-10-30 17:26:44 +08:00
committed by lijinxia
parent 111f9726d0
commit 3ffa9686ca
13 changed files with 236 additions and 118 deletions

View File

@@ -230,7 +230,7 @@ static int create_polling_job(struct polling_job_t *pjob)
static void channel_polling(struct channel_t *cnl)
{
int id;
int ret;
int jt;
struct vm_t *vm;
char *cname = cnl->name;
@@ -244,15 +244,27 @@ static void channel_polling(struct channel_t *cnl)
if (strcmp(vm->channel, "polling"))
continue;
vm_job.timer_val = atoi(vm->interval);
if (cfg_atoi(vm->interval, vm->interval_len,
&jt) == -1) {
LOGE("invalid interval (%s) in config file, exiting\n",
vm->interval);
exit(EXIT_FAILURE);
}
if (jt <= 0) {
LOGE("interval (%s) must be greater than 0, exiting\n",
vm->interval);
exit(EXIT_FAILURE);
} else
vm_job.timer_val = (uint32_t)jt;
}
LOGD("start polling job with %ds\n", vm_job.timer_val);
vm_job.fn = polling_vm;
vm_job.type = VM;
ret = create_polling_job(&vm_job);
if (ret < 0) {
LOGE("create polling job failed\n, error (%s)\n",
if (create_polling_job(&vm_job) == -1) {
LOGE("failed to create polling job\n, error (%s)\n",
strerror(errno));
exit(EXIT_FAILURE);
}