mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-06-08 10:04:42 +00:00
tools: acrn-crashlog: remove unsafe apis from android_events.c
1. Refine strings operation. 2. Remove sscanf, sprintf and strlen. 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:
@@ -12,10 +12,10 @@ extern char *loop_dev;
|
||||
#define VMEVT_HANDLED 0
|
||||
#define VMEVT_DEFER -1
|
||||
|
||||
#define IGN_SPACES "%*[ ]"
|
||||
#define IGN_RESTS "%*c"
|
||||
#define IGN_ONEWORD "%*[^ ]" IGN_SPACES
|
||||
#define VM_NAME_FMT "%8[A-Z0-9]" IGN_SPACES
|
||||
#define IGN_SPACES "%*[[[:space:]]*]"
|
||||
#define IGN_RESTS "%*[[.]*]"
|
||||
#define IGN_ONEWORD "%*[[^[:space:]]*]" IGN_SPACES
|
||||
#define VM_NAME_FMT "%[[A-Z0-9]{3}]" IGN_SPACES
|
||||
|
||||
/* These below macros were defined to obtain strings from
|
||||
* andorid history_event
|
||||
@@ -23,19 +23,16 @@ extern char *loop_dev;
|
||||
#define ANDROID_WORD_LEN 32
|
||||
|
||||
/* Strings are constructed by A-Z, len < 8, e.g., CRASH REBOOT */
|
||||
#define ANDROID_ENEVT_FMT "%8[A-Z]" IGN_SPACES
|
||||
/* Hashkeys are constructed by 0-9&a-z, len = 20, e.g., 0b34ae1afba54aee5cd0.
|
||||
* But the hashkey was printed to history_event file in andorid side by using
|
||||
* format "%22s", so also using %22 here.
|
||||
*/
|
||||
#define ANDROID_KEY_FMT "%22[0-9a-z]" IGN_SPACES
|
||||
#define ANDROID_ENEVT_FMT "%[[A-Z]{1,7}]" IGN_SPACES
|
||||
/* Hashkeys are constructed by 0-9&a-z, len = 20, e.g., 0b34ae1afba54aee5cd0. */
|
||||
#define ANDROID_KEY_FMT "%[[0-9a-z]{20}]" IGN_SPACES
|
||||
/* Strings, e.g., 2017-11-11/03:12:59 */
|
||||
#define ANDROID_LONGTIME_FMT "%20[0-9:/-]" IGN_SPACES
|
||||
#define ANDROID_LONGTIME_FMT "%[[0-9:/-]{15,20}]" IGN_SPACES
|
||||
/* It's a time or a subtype of event, e.g., JAVACRASH POWER-ON 424874:19:56 */
|
||||
#define ANDROID_TYPE_FMT "%16[A-Z0-9_:-]" IGN_SPACES
|
||||
#define ANDROID_LINE_REST_FMT "%4096[^\n]" IGN_RESTS
|
||||
#define ANDROID_TYPE_FMT "%[[A-Z0-9_:-]{3,16}]" IGN_SPACES
|
||||
#define ANDROID_LINE_REST_FMT "%[[^\n]*]" IGN_RESTS
|
||||
|
||||
void refresh_vm_history(const struct sender_t *sender,
|
||||
int (*fn)(const char*, const struct vm_t *));
|
||||
int (*fn)(const char*, size_t, const struct vm_t *));
|
||||
|
||||
#endif
|
||||
|
||||
@@ -206,6 +206,7 @@ struct conf_t conf;
|
||||
int load_conf(const char *path);
|
||||
struct trigger_t *get_trigger_by_name(char *name);
|
||||
struct log_t *get_log_by_name(char *name);
|
||||
struct vm_t *get_vm_by_name(const char *name);
|
||||
int sender_id(const struct sender_t *sender);
|
||||
struct sender_t *get_sender_by_name(char *name);
|
||||
enum event_type_t get_conf_by_wd(int wd, void **private);
|
||||
|
||||
Reference in New Issue
Block a user