mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-06-09 02:24:45 +00:00
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:
@@ -45,15 +45,19 @@ static void uptime(const struct sender_t *sender)
|
||||
if (!uptime)
|
||||
return;
|
||||
|
||||
frequency = atoi(uptime->frequency);
|
||||
if (cfg_atoi(uptime->frequency, uptime->frequency_len,
|
||||
&frequency) == -1) {
|
||||
LOGE("Invalid frequency (%s) in config file, exiting...\n",
|
||||
uptime->frequency);
|
||||
exit(-1);
|
||||
}
|
||||
if (frequency > 0)
|
||||
sleep(frequency);
|
||||
|
||||
fd = open(uptime->path, O_RDWR | O_CREAT, 0666);
|
||||
if (fd < 0)
|
||||
LOGE("open uptime_file with (%d, %s) failed, error (%s)\n",
|
||||
atoi(uptime->frequency), uptime->path,
|
||||
strerror(errno));
|
||||
frequency, uptime->path, strerror(errno));
|
||||
else
|
||||
close(fd);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user