From bf9ba474a586f6a30aed24b3bdccae55fead609a Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 30 Jul 2020 16:41:31 +0900 Subject: [PATCH] net/icmp/icmp_recvfrom.c: fix a NULL dereference Found by clang-check: icmp/icmp_recvfrom.c:374:30: warning: Dereference of null pointer (loaded from variable 'fromlen') if (fromlen == NULL && *fromlen < sizeof(struct sockaddr_in)) ^~~~~~~~ 1 warning generated. --- net/icmp/icmp_recvfrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/icmp/icmp_recvfrom.c b/net/icmp/icmp_recvfrom.c index f8cb5ca9ad..20ef214904 100644 --- a/net/icmp/icmp_recvfrom.c +++ b/net/icmp/icmp_recvfrom.c @@ -371,7 +371,7 @@ ssize_t icmp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, if (from != NULL) { - if (fromlen == NULL && *fromlen < sizeof(struct sockaddr_in)) + if (fromlen == NULL || *fromlen < sizeof(struct sockaddr_in)) { return -EINVAL; }