From 65e08b750c15ebde9c2c74ffd0cc9ebdf0f7a1ab Mon Sep 17 00:00:00 2001 From: zhanghongyu Date: Thu, 19 Jan 2023 17:08:59 +0800 Subject: [PATCH] tcp_reset: check the conn is exist when tcp_reset tcp_input: If we didn't find an active connection that expected the packet, If the SYN flag isn't set, It is an old packet and we send a RST. conn is NULL when this case Signed-off-by: zhanghongyu --- net/tcp/tcp_send.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/tcp/tcp_send.c b/net/tcp/tcp_send.c index ae231b161e..041b07fc1a 100644 --- a/net/tcp/tcp_send.c +++ b/net/tcp/tcp_send.c @@ -477,7 +477,7 @@ void tcp_reset(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn) ipv6_build_header(ipv6, dev->d_len - IPv6_HDRLEN, IP_PROTO_TCP, dev->d_ipv6addr, ipv6->srcipaddr, - IP_TTL_DEFAULT, conn->sconn.s_tclass); + IP_TTL_DEFAULT, conn ? conn->sconn.s_tclass : 0); tcp->tcpchksum = 0; tcp->tcpchksum = ~tcp_ipv6_chksum(dev); @@ -493,7 +493,7 @@ void tcp_reset(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn) ipv4_build_header(IPv4BUF, dev->d_len, IP_PROTO_TCP, &dev->d_ipaddr, (FAR in_addr_t *)ipv4->srcipaddr, - IP_TTL_DEFAULT, conn->sconn.s_tos, NULL); + IP_TTL_DEFAULT, conn ? conn->sconn.s_tos : 0, NULL); tcp->tcpchksum = 0; tcp->tcpchksum = ~tcp_ipv4_chksum(dev);