Skip to content

Commit

Permalink
net/tcp: Return -EINVAL if bind is called more than once
Browse files Browse the repository at this point in the history
Signed-off-by: wangchen <wangchen41@xiaomi.com>
  • Loading branch information
wangchen61698 authored and xiaoxiang781216 committed Aug 3, 2023
1 parent da3a75d commit bdf82d2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions net/tcp/tcp_conn.c
Expand Up @@ -325,6 +325,12 @@ static inline int tcp_ipv4_bind(FAR struct tcp_conn_s *conn,

net_lock();

if (conn->lport != 0)
{
net_unlock();
return -EINVAL;
}

/* Verify or select a local port (network byte order) */

port = tcp_selectport(PF_INET,
Expand Down Expand Up @@ -390,6 +396,12 @@ static inline int tcp_ipv6_bind(FAR struct tcp_conn_s *conn,

net_lock();

if (conn->lport != 0)
{
net_unlock();
return -EINVAL;
}

/* Verify or select a local port (network byte order) */

/* The port number must be unique for this address binding */
Expand Down

0 comments on commit bdf82d2

Please sign in to comment.