From 5bd75183438cbc2e61575dd6e3344f2ec542cf4d Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Fri, 22 Jan 2021 20:19:44 +0100 Subject: [PATCH] netdb: Accept '0' as service in lwip_getaddrinfo Fixes bug #59925 --- src/api/netdb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/api/netdb.c b/src/api/netdb.c index b6891de7..ee782978 100644 --- a/src/api/netdb.c +++ b/src/api/netdb.c @@ -305,7 +305,11 @@ lwip_getaddrinfo(const char *nodename, const char *servname, /* service name specified: convert to port number * @todo?: currently, only ASCII integers (port numbers) are supported (AI_NUMERICSERV)! */ port_nr = atoi(servname); - if ((port_nr <= 0) || (port_nr > 0xffff)) { + if (port_nr == 0 && (servname[0] != '0')) { + /* atoi failed - service was not numeric */ + return EAI_SERVICE; + } + if ((port_nr < 0) || (port_nr > 0xffff)) { return EAI_SERVICE; } }