lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [bug #59925] lwip_getaddrinfo returns EAI_SERVICE for port


From: Viktor Babrian
Subject: [lwip-devel] [bug #59925] lwip_getaddrinfo returns EAI_SERVICE for port 0
Date: Fri, 22 Jan 2021 03:01:31 -0500 (EST)
User-agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0

URL:
  <https://savannah.nongnu.org/bugs/?59925>

                 Summary: lwip_getaddrinfo returns EAI_SERVICE for port 0
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: boborjan
            Submitted on: Fri 22 Jan 2021 08:01:29 AM UTC
                Category: None
                Severity: 3 - Normal
              Item Group: Faulty Behaviour
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None
            lwIP version: 2.1.1

    _______________________________________________________

Details:

Hi,

lwip_getaddrinfo() incorrectly returns error EAI_SERVICE for a presumably
valid call: (1: it runs on major ip stacks like the one of Linux and Windows,
2: it should be fine according to the manual of getaddrinfo)

struct addrinfo hints, *res = NULL;
char serv[6] = "0";

memset(&hints, 0, sizeof(hints));
/* set-up hints structure */
hints.ai_family   = af;
hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = IPPROTO_UDP;
error = getaddrinfo(NULL, serv, &hints, &res);   --> EAI_SERVICE

Debugging shows that the return is performed in netdb.c, near line 305, in
function lwip_getaddr():

if (servname != NULL) {
    /* 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)) {
      return EAI_SERVICE;
    }
 }

To my understanding. port_nr == 0 is a valid value for dynamic port
allocation, and bind() will handle it accordingly. A possible solution would
be:

if ((port_nr < 0) || (port_nr > 0xffff)) {
     return EAI_SERVICE;
}

Regards,
Viktor




    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?59925>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]