mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
net/tcp: Return -EINVAL if bind is called more than once
Signed-off-by: wangchen <wangchen41@xiaomi.com>
This commit is contained in:
@@ -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,
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user