mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-06-09 02:24:45 +00:00
tools: acrn-crashlog: Fix potential issues under acrnprobe
This patch is to fix potential issues, which are reported by static analysis tool, for acrnprobe. Changes: 1. Check the return value of sender_id() and get_sender_by_name(), since it could be -1 or NULL. 2. Remove the parameter len from create_event, take parameter path as a NULL-terminated string as default. 3. Modify for_each_* functions to avoid overflow. Signed-off-by: Liu Xinwu <xinwu.liu@intel.com> Reviewed-by: Zhi Jin <zhi.jin@intel.com> Acked-by: Chen Gang <gang.c.chen@intel.com>
This commit is contained in:
@@ -132,6 +132,9 @@ void hist_raise_event(char *event, char *type, char *log, char *lastuptime,
|
||||
|
||||
/* here means user have configured the crashlog sender */
|
||||
crashlog = get_sender_by_name("crashlog");
|
||||
if (!crashlog)
|
||||
return;
|
||||
|
||||
maxlines = atoi(crashlog->maxlines);
|
||||
if (++current_lines >= maxlines) {
|
||||
LOGW("lines of (%s) meet quota %d, backup... Pls clean!\n",
|
||||
@@ -139,9 +142,11 @@ void hist_raise_event(char *event, char *type, char *log, char *lastuptime,
|
||||
backup_history();
|
||||
}
|
||||
|
||||
get_current_time_long(eventtime);
|
||||
entry.eventtime = eventtime;
|
||||
ret = get_current_time_long(eventtime);
|
||||
if (ret <= 0)
|
||||
return;
|
||||
|
||||
entry.eventtime = eventtime;
|
||||
entry_to_history_line(&entry, line);
|
||||
ret = append_file(history_file, line);
|
||||
if (ret < 0) {
|
||||
@@ -165,6 +170,9 @@ void hist_raise_uptime(char *lastuptime)
|
||||
|
||||
/* user have configured the crashlog sender */
|
||||
crashlog = get_sender_by_name("crashlog");
|
||||
if (!crashlog)
|
||||
return;
|
||||
|
||||
uptime = crashlog->uptime;
|
||||
uptime_hours = atoi(uptime->eventhours);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user