lwip - Added check for previously-bound socket

Avoids what turns into an infinite loop in lwip's internals
pull/2580/head
Christopher Haster 2016-08-29 18:47:30 -05:00
parent 9111aa4c2d
commit c3130e51e4
1 changed files with 5 additions and 0 deletions

View File

@ -278,6 +278,11 @@ static int lwip_socket_bind(nsapi_stack_t *stack, nsapi_socket_t handle, nsapi_a
return NSAPI_ERROR_PARAMETER;
}
if ((s->conn->type == NETCONN_TCP && s->conn->pcb.tcp->local_port != 0) ||
(s->conn->type == NETCONN_UDP && s->conn->pcb.udp->local_port != 0)) {
return NSAPI_ERROR_PARAMETER;
}
err_t err = netconn_bind(s->conn, (ip_addr_t *)addr.bytes, port);
return lwip_err_remap(err);
}