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:
Liu, Xinwu
2018-09-25 10:08:24 +08:00
committed by Xie, Nanlin
parent 48ce01a52f
commit 5ecf1078ca
8 changed files with 269 additions and 311 deletions

View File

@@ -15,22 +15,23 @@
* Get the length of line.
*
* @param str Start address of line.
* @param size Size of searched space.
*
* @return the length of line if successful, or -1 if not.
* This function return length of string if string doesn't contain \n.
* @return the length of line (excludes \n) if successful, or -1 if not.
* This function return -1 if string doesn't contain \n.
*/
int strlinelen(char *str)
ssize_t strlinelen(const char *str, size_t size)
{
char *tag;
char *tail;
if (!str)
return -1;
tag = strchr(str, '\n');
if (tag)
return tag - str + 1;
tail = memchr(str, '\n', size);
if (tail)
return tail - str;
return strlen(str);
return -1;
}
/**