fixed bug #49726: setsockopt() set TCP_NODELAY TCP_KEEPALIVE ... with a listen state TCP will crash

This commit is contained in:
goldsimon 2016-11-28 15:50:59 +01:00
parent 2a882b6387
commit b934c3f471

View File

@ -2074,6 +2074,9 @@ lwip_getsockopt_impl(int s, int level, int optname, void *optval, socklen_t *opt
case IPPROTO_TCP: case IPPROTO_TCP:
/* Special case: all IPPROTO_TCP option take an int */ /* Special case: all IPPROTO_TCP option take an int */
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, *optlen, int, NETCONN_TCP); LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, *optlen, int, NETCONN_TCP);
if (sock->conn->pcb.tcp->state == LISTEN) {
return EINVAL;
}
switch (optname) { switch (optname) {
case TCP_NODELAY: case TCP_NODELAY:
*(int*)optval = tcp_nagle_disabled(sock->conn->pcb.tcp); *(int*)optval = tcp_nagle_disabled(sock->conn->pcb.tcp);
@ -2467,6 +2470,9 @@ lwip_setsockopt_impl(int s, int level, int optname, const void *optval, socklen_
case IPPROTO_TCP: case IPPROTO_TCP:
/* Special case: all IPPROTO_TCP option take an int */ /* Special case: all IPPROTO_TCP option take an int */
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, optlen, int, NETCONN_TCP); LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, optlen, int, NETCONN_TCP);
if (sock->conn->pcb.tcp->state == LISTEN) {
return EINVAL;
}
switch (optname) { switch (optname) {
case TCP_NODELAY: case TCP_NODELAY:
if (*(const int*)optval) { if (*(const int*)optval) {