Skip to content

Commit fb7ffcb

Browse files
authored
Merge pull request #2580 from geky/nsapi-bind-again
lwip - Add check for previously-bound socket
2 parents c518a61 + c3130e5 commit fb7ffcb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

features/net/FEATURE_IPV4/lwip-interface/lwip_stack.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,11 @@ static int lwip_socket_bind(nsapi_stack_t *stack, nsapi_socket_t handle, nsapi_a
278278
return NSAPI_ERROR_PARAMETER;
279279
}
280280

281+
if ((s->conn->type == NETCONN_TCP && s->conn->pcb.tcp->local_port != 0) ||
282+
(s->conn->type == NETCONN_UDP && s->conn->pcb.udp->local_port != 0)) {
283+
return NSAPI_ERROR_PARAMETER;
284+
}
285+
281286
err_t err = netconn_bind(s->conn, (ip_addr_t *)addr.bytes, port);
282287
return lwip_err_remap(err);
283288
}

0 commit comments

Comments
 (0)