tools:acrn-crashlog: Change the algorithm of generating event key

Acrnprobe is using SHA to generate ids for events. These ids are only used
to index events, not for cryptographic purpose.

This patch unify the generating algorithm of short and long ids to
SHA256.

Tracked-On: #1024
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:
Liu, Xinwu
2018-09-11 16:48:47 +08:00
committed by lijinxia
parent b1ba12ae1b
commit 876cc68311
5 changed files with 71 additions and 155 deletions

View File

@@ -357,7 +357,7 @@ static void telemd_send_crash(struct event_t *e)
return;
}
eventid = generate_eventid256(class);
eventid = generate_event_id((const char *)class, NULL, KEY_LONG);
if (eventid == NULL) {
LOGE("generate eventid failed, error (%s)\n", strerror(errno));
goto free_class;
@@ -436,7 +436,7 @@ static void telemd_send_info(struct event_t *e)
return;
}
eventid = generate_eventid256(class);
eventid = generate_event_id((const char *)class, NULL, KEY_LONG);
if (eventid == NULL) {
LOGE("generate eventid failed, error (%s)\n", strerror(errno));
goto free_class;
@@ -608,7 +608,7 @@ static int telemd_new_vmevent(const char *line_to_sync,
goto free_vmlogpath;
}
eventid = generate_eventid256(class);
eventid = generate_event_id((const char *)class, NULL, KEY_LONG);
if (eventid == NULL) {
LOGE("generate eventid failed, error (%s)\n", strerror(errno));
ret = VMEVT_DEFER;
@@ -739,7 +739,7 @@ static void crashlog_send_crash(struct event_t *e)
/* change the class for other senders */
e->private = (void *)crash;
key = generate_event_id("CRASH", crash->name);
key = generate_event_id("CRASH", (const char *)crash->name, KEY_SHORT);
if (key == NULL) {
LOGE("generate event id failed, error (%s)\n",
strerror(errno));
@@ -818,7 +818,8 @@ static void crashlog_send_info(struct event_t *e)
int id;
struct info_t *info = (struct info_t *)e->private;
struct log_t *log;
char *key = generate_event_id("INFO", info->name);
char *key = generate_event_id("INFO", (const char *)info->name,
KEY_SHORT);
if (key == NULL) {
LOGE("generate event id failed, error (%s)\n",
@@ -862,7 +863,7 @@ static void crashlog_send_reboot(void)
return;
if (swupdated(crashlog)) {
key = generate_event_id("INFO", "SWUPDATE");
key = generate_event_id("INFO", "SWUPDATE", KEY_SHORT);
if (key == NULL) {
LOGE("generate event id failed, error (%s)\n",
strerror(errno));
@@ -874,7 +875,7 @@ static void crashlog_send_reboot(void)
}
read_startupreason(reason, sizeof(reason));
key = generate_event_id("REBOOT", reason);
key = generate_event_id("REBOOT", (const char *)reason, KEY_SHORT);
if (key == NULL) {
LOGE("generate event id failed, error (%s)\n",
strerror(errno));
@@ -931,7 +932,7 @@ static int crashlog_new_vmevent(const char *line_to_sync,
return ret;
}
key = generate_event_id("SOS", vmkey);
key = generate_event_id("SOS", (const char *)vmkey, KEY_SHORT);
if (key == NULL) {
LOGE("generate event id failed, error (%s)\n",
strerror(errno));