You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/07/29 05:53:24 UTC
[incubator-nuttx] branch master updated: make sure conn's domain is match with addr's family
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new b232508bd9 make sure conn's domain is match with addr's family
b232508bd9 is described below
commit b232508bd9b37e8a2f295504e028b1a5d22b2622
Author: liyi <li...@xiaomi.com>
AuthorDate: Fri Jul 29 11:11:46 2022 +0800
make sure conn's domain is match with addr's family
---
net/inet/inet_sockif.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/net/inet/inet_sockif.c b/net/inet/inet_sockif.c
index 061e6a6836..82d1416510 100644
--- a/net/inet/inet_sockif.c
+++ b/net/inet/inet_sockif.c
@@ -722,15 +722,23 @@ static int inet_connect(FAR struct socket *psock,
#if defined(CONFIG_NET_TCP) && defined(NET_TCP_HAVE_STACK)
case SOCK_STREAM:
{
- FAR struct socket_conn_s *conn = psock->s_conn;
+ FAR struct tcp_conn_s *conn = psock->s_conn;
/* Verify that the socket is not already connected */
- if (_SS_ISCONNECTED(conn->s_flags))
+ if (_SS_ISCONNECTED(conn->sconn.s_flags))
{
return -EISCONN;
}
+#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
+ if (conn->domain != addr->sa_family)
+ {
+ nerr("conn's domain must be the same as addr's family!\n");
+ return -EPROTOTYPE;
+ }
+
+#endif
/* It's not ... Connect the TCP/IP socket */
return psock_tcp_connect(psock, addr);
@@ -756,6 +764,14 @@ static int inet_connect(FAR struct socket *psock,
/* Perform the connect/disconnect operation */
conn = (FAR struct udp_conn_s *)psock->s_conn;
+#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
+ if (conn->domain != addr->sa_family)
+ {
+ nerr("conn's domain must be the same as addr's family!\n");
+ return -EPROTOTYPE;
+ }
+
+#endif
ret = udp_connect(conn, addr);
if (ret < 0 || addr == NULL)
{