tools: acrn-crashlog: remove unsafe api sscanf

Use str_split_ere instead of sscanf.

Tracked-On: #1254
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
This commit is contained in:
Liu, Xinwu
2018-09-25 11:14:55 +08:00
committed by Xie, Nanlin
parent fb0292846d
commit fe4d503c3d
2 changed files with 20 additions and 20 deletions

View File

@@ -572,8 +572,10 @@ static int telemd_new_vmevent(const char *line_to_sync,
ANDROID_ENEVT_FMT ANDROID_KEY_FMT ANDROID_LONGTIME_FMT
ANDROID_TYPE_FMT ANDROID_LINE_REST_FMT;
res = sscanf(line_to_sync, vm_format, event, vmkey, longtime,
type, rest);
res = str_split_ere(line_to_sync, len, vm_format, strlen(vm_format),
event, sizeof(event), vmkey, sizeof(vmkey),
longtime, sizeof(longtime),
type, sizeof(type), rest, sizeof(rest));
if (res != 5) {
LOGE("get an invalid line from (%s), skip\n", vm->name);
return VMEVT_HANDLED;
@@ -917,8 +919,10 @@ static int crashlog_new_vmevent(const char *line_to_sync,
ANDROID_ENEVT_FMT ANDROID_KEY_FMT ANDROID_LONGTIME_FMT
ANDROID_TYPE_FMT ANDROID_LINE_REST_FMT;
res = sscanf(line_to_sync, vm_format, event, vmkey, longtime,
type, rest);
res = str_split_ere(line_to_sync, len, vm_format, strlen(vm_format),
event, sizeof(event), vmkey, sizeof(vmkey),
longtime, sizeof(longtime),
type, sizeof(type), rest, sizeof(rest));
if (res != 5) {
LOGE("get an invalid line from (%s), skip\n", vm->name);
return ret;