Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/tcp: Return -EINVAL if bind is called more than once #10022

Merged
merged 1 commit into from Aug 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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