diff --git a/libs/libc/netdb/lib_getaddrinfo.c b/libs/libc/netdb/lib_getaddrinfo.c index 2d5ae0f6c7..0e2e69f550 100644 --- a/libs/libc/netdb/lib_getaddrinfo.c +++ b/libs/libc/netdb/lib_getaddrinfo.c @@ -169,7 +169,7 @@ int getaddrinfo(FAR const char *hostname, FAR const char *servname, FAR char *endp; port = strtol(servname, &endp, 10); - if (port > 0 && port <= 65535 && *endp == '\0') + if (port >= 0 && port <= 65535 && *endp == '\0') { /* Force network byte order */ diff --git a/libs/libc/netdb/lib_getnameinfo.c b/libs/libc/netdb/lib_getnameinfo.c index 333a335e15..6c517e8ccf 100644 --- a/libs/libc/netdb/lib_getnameinfo.c +++ b/libs/libc/netdb/lib_getnameinfo.c @@ -53,7 +53,7 @@ int getnameinfo(FAR const struct sockaddr *addr, socklen_t addrlen, int ret; if (addr && addr->sa_family == AF_INET && - addrlen == sizeof(struct sockaddr_in)) + addrlen >= sizeof(struct sockaddr_in)) { FAR const struct sockaddr_in *sa_in;