mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-06 06:39:46 +00:00
fixed bug #49726: setsockopt() set TCP_NODELAY TCP_KEEPALIVE ... with a listen state TCP will crash
This commit is contained in:
parent
2a882b6387
commit
b934c3f471
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user