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:
xiaojin2
2018-06-08 13:15:29 +08:00
committed by lijinxia
parent 0c39b9cddc
commit 3e8e607d5b
7 changed files with 123 additions and 67 deletions

View File

@@ -233,7 +233,7 @@ static struct crash_t *crash_reclassify_by_content(struct crash_t *rcrash,
return NULL;
if (trfile) {
ret = read_full_binary_file(trfile, &size, &file);
ret = read_file(trfile, &size, &file);
if (ret == -1) {
LOGE("read %s failed, error (%s)\n",
trfile, strerror(errno));