mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-04 18:30:18 +00:00
tools: acrn-crashlog: remove unsafe apis in usercrash
Since strlen/vsnprintf/ato* api are not safe, so use strnlen instead of strlen, use vasprintf instead of vsnprintf and use strtol instead of atoi. Tracked-On: #1254 Signed-off-by: xiaojin2 <xiaojing.liu@intel.com> Reviewed-by: Huang Yonghua <yonghua.huang@intel.com> Reviewed-by: Liu, Xinwu <xinwu.liu@intel.com> Acked-by: Chen Gang <gang.c.chen@intel.com>
This commit is contained in:
@@ -85,7 +85,8 @@ static int usercrashd_connect(int pid, int *usercrashd_socket,
|
||||
LOGE("crash process name is NULL\n");
|
||||
return -1;
|
||||
}
|
||||
sockfd = socket_local_client(SOCKET_NAME, SOCK_SEQPACKET);
|
||||
sockfd = socket_local_client(SOCKET_NAME, strlen(SOCKET_NAME),
|
||||
SOCK_SEQPACKET);
|
||||
if (sockfd == -1) {
|
||||
LOGE("failed to connect to usercrashd, error (%s)\n",
|
||||
strerror(errno));
|
||||
@@ -212,8 +213,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (argc == 4) {
|
||||
/* it's from coredump */
|
||||
pid = atoi(argv[1]);
|
||||
sig = atoi(argv[3]);
|
||||
pid = (int)strtol(argv[1], NULL, 10);
|
||||
sig = (int)strtol(argv[3], NULL, 10);
|
||||
ret = usercrashd_connect(pid, &sock, &out_fd, argv[2]);
|
||||
if (ret) {
|
||||
LOGE("usercrashd_connect failed, error (%s)\n",
|
||||
|
Reference in New Issue
Block a user