aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-02-21 20:20:33 +0100
committerChristian Grothoff <christian@grothoff.org>2017-02-21 20:20:33 +0100
commit647d88d649c267220feb8b5f53ec3e96359a72fc (patch)
treef0e78fbaed43f946b9e49ab42942303697584fa6
parent0c7478479c31e75392774b17d850c4325e4ff9a8 (diff)
fix sun_len issue (#4816) by adding test and fixing typo
-rw-r--r--configure.ac10
-rw-r--r--src/arm/gnunet-service-arm.c2
-rw-r--r--src/transport/plugin_transport_tcp.c2
-rw-r--r--src/transport/plugin_transport_unix.c6
-rw-r--r--src/util/client.c4
-rw-r--r--src/util/connection.c4
-rw-r--r--src/util/service.c2
-rw-r--r--src/util/service_new.c2
-rw-r--r--src/util/test_server_with_client_unix.c2
9 files changed, 22 insertions, 12 deletions
diff --git a/configure.ac b/configure.ac
index b31d0a6c79..7f9cc21971 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1032,6 +1032,16 @@ AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
#include <netinet/in.h>
])
+AC_CHECK_MEMBER([struct sockaddr_un.sun_len],
+ [ AC_DEFINE(HAVE_SOCKADDR_UN_SUN_LEN, 1, [Do we have sockaddr_un.sun_len?])
+ ],
+ [],
+ [
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ #include <sys/un.h>
+ ])
+
# Checks for library functions.
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c
index 7af3659a47..4f3e964e31 100644
--- a/src/arm/gnunet-service-arm.c
+++ b/src/arm/gnunet-service-arm.c
@@ -290,7 +290,7 @@ add_unixpath (struct sockaddr **saddrs,
if (GNUNET_YES == abstract)
un->sun_path[0] = '\0';
#endif
-#if HAVE_SOCKADDR_IN_SIN_LEN
+#if HAVE_SOCKADDR_UN_SUN_LEN
un->sun_len = (u_char) sizeof (struct sockaddr_un);
#endif
*saddrs = (struct sockaddr *) un;
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index 4ed5b38f77..34bbd00e09 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -549,7 +549,7 @@ add_unixpath (struct sockaddr **saddrs,
if (GNUNET_YES == abstract)
un->sun_path[0] = '\0';
#endif
-#if HAVE_SOCKADDR_IN_SIN_LEN
+#if HAVE_SOCKADDR_UN_SUN_LEN
un->sun_len = (u_char) sizeof (struct sockaddr_un);
#endif
*saddrs = (struct sockaddr *) un;
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c
index 49a5e89ed1..6bcb7290f2 100644
--- a/src/transport/plugin_transport_unix.c
+++ b/src/transport/plugin_transport_unix.c
@@ -566,7 +566,7 @@ unix_address_to_sockaddr (const char *unixpath,
GNUNET_memcpy (un->sun_path, unixpath, slen);
un->sun_path[slen] = '\0';
slen = sizeof (struct sockaddr_un);
-#if HAVE_SOCKADDR_IN_SIN_LEN
+#if HAVE_SOCKADDR_UN_SUN_LEN
un->sun_len = (u_char) slen;
#endif
(*sock_len) = slen;
@@ -1229,7 +1229,7 @@ unix_plugin_select_read (void *cls)
{
struct Plugin *plugin = cls;
const struct GNUNET_SCHEDULER_TaskContext *tc;
-
+
plugin->read_task = NULL;
tc = GNUNET_SCHEDULER_get_task_context ();
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY))
@@ -1252,7 +1252,7 @@ unix_plugin_select_write (void *cls)
{
struct Plugin *plugin = cls;
const struct GNUNET_SCHEDULER_TaskContext *tc;
-
+
plugin->write_task = NULL;
tc = GNUNET_SCHEDULER_get_task_context ();
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY))
diff --git a/src/util/client.c b/src/util/client.c
index 06f6ebc329..a5e04d7b27 100644
--- a/src/util/client.c
+++ b/src/util/client.c
@@ -491,8 +491,8 @@ try_unixpath (const char *service_name,
s_un.sun_path[0] = '\0';
}
#endif
-#if HAVE_SOCKADDR_IN_SIN_LEN
- un.sun_len = (u_char) sizeof (struct sockaddr_un);
+#if HAVE_SOCKADDR_UN_SUN_LEN
+ s_un.sun_len = (u_char) sizeof (struct sockaddr_un);
#endif
sock = GNUNET_NETWORK_socket_create (AF_UNIX,
SOCK_STREAM,
diff --git a/src/util/connection.c b/src/util/connection.c
index 6d30704150..02dd9f9911 100644
--- a/src/util/connection.c
+++ b/src/util/connection.c
@@ -902,7 +902,7 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct GNUNET_CONFIGURA
un->sun_path[0] = '\0';
}
#endif
-#if HAVE_SOCKADDR_IN_SIN_LEN
+#if HAVE_SOCKADDR_UN_SUN_LEN
un->sun_len = (u_char) sizeof (struct sockaddr_un);
#endif
connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
@@ -1012,7 +1012,7 @@ GNUNET_CONNECTION_create_from_sockaddr (int af_family,
return NULL;
}
return GNUNET_CONNECTION_connect_socket (s,
- serv_addr,
+ serv_addr,
addrlen);
}
diff --git a/src/util/service.c b/src/util/service.c
index 3beb4a085b..11128425de 100644
--- a/src/util/service.c
+++ b/src/util/service.c
@@ -481,7 +481,7 @@ add_unixpath (struct sockaddr **saddrs,
if (GNUNET_YES == abstract)
un->sun_path[0] = '\0';
#endif
-#if HAVE_SOCKADDR_IN_SIN_LEN
+#if HAVE_SOCKADDR_UN_SUN_LEN
un->sun_len = (u_char) sizeof (struct sockaddr_un);
#endif
*saddrs = (struct sockaddr *) un;
diff --git a/src/util/service_new.c b/src/util/service_new.c
index 00d05dacc3..90829c08c1 100644
--- a/src/util/service_new.c
+++ b/src/util/service_new.c
@@ -519,7 +519,7 @@ add_unixpath (struct sockaddr **saddrs,
if (GNUNET_YES == abstract)
un->sun_path[0] = '\0';
#endif
-#if HAVE_SOCKADDR_IN_SIN_LEN
+#if HAVE_SOCKADDR_UN_SUN_LEN
un->sun_len = (u_char) sizeof (struct sockaddr_un);
#endif
*saddrs = (struct sockaddr *) un;
diff --git a/src/util/test_server_with_client_unix.c b/src/util/test_server_with_client_unix.c
index d240f1a88a..8fabbe210f 100644
--- a/src/util/test_server_with_client_unix.c
+++ b/src/util/test_server_with_client_unix.c
@@ -123,7 +123,7 @@ task (void *cls)
memset (&un, 0, sizeof (un));
un.sun_family = AF_UNIX;
strncpy(un.sun_path, unixpath, sizeof (un.sun_path) - 1);
-#if HAVE_SOCKADDR_IN_SIN_LEN
+#if HAVE_SOCKADDR_UN_SUN_LEN
un.sun_len = (u_char) sizeof (un);
#endif