BugID:23251508: fixed bug setsockopt() set TCP_NODELAY TCP_KEEPALIVE ... with a listen state TCP will crash
commit
Author: goldsimon
Date:   Mon Nov 28 15:50:59 2016 +0100
@@ -2578,6 +2578,10 @@ lwip_getsockopt_impl(int s, int level, int optname, void *optval, socklen_t *opt
case IPPROTO_TCP:
/* Special case: all IPPROTO_TCP option take an int */
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, *optlen, int, NETCONN_TCP);
+ if (sock->conn->pcb.tcp->state == LISTEN) {
+ done_socket(sock);
+ return EINVAL;
+ }
switch (optname) {
case TCP_NODELAY:
*(int*)optval = tcp_nagle_disabled(sock->conn->pcb.tcp);
@@ -3030,6 +3034,10 @@ lwip_setsockopt_impl(int s, int level, int optname, const void *optval, socklen_
case IPPROTO_TCP:
/* Special case: all IPPROTO_TCP option take an int */
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, optlen, int, NETCONN_TCP);
+ if (sock->conn->pcb.tcp->state == LISTEN) {
+ done_socket(sock);
+ return EINVAL;
+ }
switch (optname) {
case TCP_NODELAY:
if (*(const int*)optval) {
