Skip to content

Commit b6372ea

Browse files
ozhurakijukkar
authored andcommitted
net: tcp2: Fix the IPv4 endpoint assignment in net_tcp_connect()
Assigning the allocated IPv4 endpoint as struct sockaddr leads to the memory overwrite, assign the correct structure, i.e. struct sockaddr_in. Signed-off-by: Oleg Zhurakivskyy <[email protected]>
1 parent 762b521 commit b6372ea

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

subsys/net/ip/tcp2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ int net_tcp_connect(struct net_context *context,
10641064
ip4 = net_if_ipv4_select_src_addr(net_context_get_iface(context),
10651065
(struct in_addr *)remote_addr);
10661066
conn->src->sin.sin_addr = *ip4;
1067-
conn->dst->sa = *remote_addr;
1067+
conn->dst->sin.sin_addr = ((struct sockaddr_in *)remote_addr)->sin_addr;
10681068
break;
10691069

10701070
case AF_INET6:

0 commit comments

Comments
 (0)