From 7e04b93a77e504710b007ed5f100fbbb7eefb64c Mon Sep 17 00:00:00 2001 From: "yilu.myl" Date: Fri, 29 Apr 2022 21:30:31 +0800 Subject: [PATCH] IssueID:1500:add check for the inet_aton [Detail] Issue description: In other places, the return value of inet_aton is always checked. So the whitescan ask for the same check here. Solution: Add check of the return value. [Verified Cases] Build Pass: eduk1_demo Test Pass: eduk1_demo Change-Id: I3614c162c5ed7a1222c4b1d8ec7f4e1b1bc612c3 Signed-off-by: yilu.myl --- components/amp_adapter/platform/aos/network/aos_udp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/amp_adapter/platform/aos/network/aos_udp.c b/components/amp_adapter/platform/aos/network/aos_udp.c index 0bc33cb28e..188dacaefe 100644 --- a/components/amp_adapter/platform/aos/network/aos_udp.c +++ b/components/amp_adapter/platform/aos/network/aos_udp.c @@ -166,7 +166,11 @@ int aos_udp_create_without_connect(const char *host, unsigned short port) memset(&local_addr, 0x00, sizeof(local_addr)); local_addr.sin_family = AF_INET; if (NULL != host) { - inet_aton(host, &local_addr.sin_addr); + if (inet_aton(host, &local_addr.sin_addr) == 0) { + close(socket_id); + platform_err("inet_aton failed\r\n"); + return (intptr_t)-1; + } } else { local_addr.sin_addr.s_addr = htonl(INADDR_ANY); } -- GitLab