buglwIP - A Lightweight TCP/IP stack - Bugs: bug #55604, UDP can bind to same port when use...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #55604: UDP can bind to same port when use IPv4 ANY and IPv6 ANY ,SO_REUSEADDR is disable and IPV6_V6ONLY is disable

Submitted by:  vinu <vineeshvinu>
Submitted on:  Tue 29 Jan 2019 04:24:14 PM UTC  
 
Category:  UDP Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Planned Release:  None
lwIP version:  2.1.1

Tue 29 Jan 2019 04:24:14 PM UTC, original submission:  

Below bind will be success since the check inside udp_bind will not match IPv4 any and IPv6 Any type, please check once
IP_GET_TYPE(&ipcb->local_ip) will be 0 and IP_GET_TYPE(ipaddr) is 46
if ((ipcb->local_port == port) &&
              (IP_GET_TYPE(&ipcb->local_ip) == IP_GET_TYPE(ipaddr)) &&
              /* IP address matches or any IP used? */
              (ip_addr_cmp(&ipcb->local_ip, ipaddr) ||
              ip_addr_isany(ipaddr) ||
              ip_addr_isany(&ipcb->local_ip))) {
            /* other PCB already binds to this local IP and port */
            LWIP_DEBUGF(UDP_DEBUG,
                        ("udp_bind: local port %"U16_F" already bound by another pcb\n", port));
            return ERR_USE;
          }

SO_REUSEADDR = disable
IPV6_V6ONLY  = disable
void test2_cmd(unsigned int p0, unsigned int p1, unsigned int p2, unsigned int p3)
{
int sock4, sock6;
struct sockaddr_in sin;
struct sockaddr_in6 sin6;
int ret;

sock4 = socket(AF_INET, SOCK_DGRAM, 0);
sock6 = socket(AF_INET6, SOCK_DGRAM, 0);

sin.sin_family = AF_INET;
sin.sin_port = htons(4444);
inet_pton(AF_INET, "0.0.0.0", &sin.sin_addr);

sin6.sin6_family = AF_INET6;
sin6.sin6_port = htons(4444);
sin6.sin6_flowinfo = 0;
inet_pton(AF_INET6, "::", &sin6.sin6_addr);

int reuse = 0;
ret = setsockopt(sock4, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse));
if (ret < 0) {
perror("reuse4");
}

ret = setsockopt(sock6, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse));
if (ret < 0) {
perror("reuse6");
}

int v6only = 0;
ret = setsockopt(sock6, IPPROTO_IPV6, IPV6_V6ONLY, &v6only, sizeof(v6only));
if (ret < 0) {
perror("setsockopt");
}

ret = bind(sock4, (struct sockaddr*)&sin, sizeof(sin));
if (ret < 0) {
perror("bind4");
}

ret = bind(sock6, (struct sockaddr*)&sin6, sizeof(sin6));
if (ret < 0) {
perror("bind6");
}

vinu <vineeshvinu>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by vineeshvinu (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    No changes have been made to this item

    Back to the top


    Powered by Savane 3.5