aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/client.c30
-rw-r--r--src/util/connection.c15
-rw-r--r--src/util/disk.c12
-rw-r--r--src/util/network.c28
-rw-r--r--src/util/resolver.conf.in2
-rw-r--r--src/util/server.c2
-rw-r--r--src/util/service.c24
-rw-r--r--src/util/test_connection.c6
-rw-r--r--src/util/test_connection_addressing.c2
-rw-r--r--src/util/test_connection_receive_cancel.c6
-rw-r--r--src/util/test_connection_timeout.c6
-rw-r--r--src/util/test_server_with_client_unix.c7
12 files changed, 87 insertions, 53 deletions
diff --git a/src/util/client.c b/src/util/client.c
index 64960f232..30c80bf03 100644
--- a/src/util/client.c
+++ b/src/util/client.c
@@ -251,9 +251,7 @@ try_unixpath (const char *service_name,
251 struct sockaddr_un s_un; 251 struct sockaddr_un s_un;
252 252
253 unixpath = NULL; 253 unixpath = NULL;
254 if ((GNUNET_OK == 254 if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "UNIXPATH", &unixpath)) &&
255 GNUNET_CONFIGURATION_get_value_filename (cfg, service_name,
256 "UNIXPATH", &unixpath)) &&
257 (0 < strlen (unixpath))) 255 (0 < strlen (unixpath)))
258 { 256 {
259 /* We have a non-NULL unixpath, need to validate it */ 257 /* We have a non-NULL unixpath, need to validate it */
@@ -301,8 +299,7 @@ test_service_configuration (const char *service_name,
301#if AF_UNIX 299#if AF_UNIX
302 char *unixpath = NULL; 300 char *unixpath = NULL;
303 301
304 if ((GNUNET_OK == 302 if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "UNIXPATH", &unixpath)) &&
305 GNUNET_CONFIGURATION_get_value_filename (cfg, service_name, "UNIXPATH", &unixpath)) &&
306 (0 < strlen (unixpath))) 303 (0 < strlen (unixpath)))
307 ret = GNUNET_OK; 304 ret = GNUNET_OK;
308 GNUNET_free_non_null (unixpath); 305 GNUNET_free_non_null (unixpath);
@@ -832,12 +829,11 @@ GNUNET_CLIENT_service_test (const char *service,
832 { 829 {
833 /* probe UNIX support */ 830 /* probe UNIX support */
834 struct sockaddr_un s_un; 831 struct sockaddr_un s_un;
832 size_t slen;
835 char *unixpath; 833 char *unixpath;
836 834
837 unixpath = NULL; 835 unixpath = NULL;
838 if ((GNUNET_OK == 836 if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, service, "UNIXPATH", &unixpath)) && (0 < strlen (unixpath))) /* We have a non-NULL unixpath, does that mean it's valid? */
839 GNUNET_CONFIGURATION_get_value_filename (cfg, service, "UNIXPATH", &unixpath)) &&
840 (0 < strlen (unixpath))) /* We have a non-NULL unixpath, does that mean it's valid? */
841 { 837 {
842 if (strlen (unixpath) >= sizeof (s_un.sun_path)) 838 if (strlen (unixpath) >= sizeof (s_un.sun_path))
843 { 839 {
@@ -856,13 +852,21 @@ GNUNET_CLIENT_service_test (const char *service,
856 { 852 {
857 memset (&s_un, 0, sizeof (s_un)); 853 memset (&s_un, 0, sizeof (s_un));
858 s_un.sun_family = AF_UNIX; 854 s_un.sun_family = AF_UNIX;
859 strncpy (s_un.sun_path, unixpath, sizeof (s_un.sun_path) - 1); 855 slen = strlen (unixpath) + 1;
856 if (slen >= sizeof (s_un.sun_path))
857 slen = sizeof (s_un.sun_path) - 1;
858 memcpy (s_un.sun_path, unixpath, slen);
859 s_un.sun_path[slen] = '\0';
860 slen = sizeof (struct sockaddr_un);
861#if LINUX
862 s_un.sun_path[0] = '\0';
863#endif
860#if HAVE_SOCKADDR_IN_SIN_LEN 864#if HAVE_SOCKADDR_IN_SIN_LEN
861 s_un.sun_len = (u_char) sizeof (struct sockaddr_un); 865 s_un.sun_len = (u_char) slen;
862#endif 866#endif
863 if (GNUNET_OK != 867 if (GNUNET_OK !=
864 GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_un, 868 GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_un,
865 sizeof (struct sockaddr_un))) 869 slen, GNUNET_BIND_EXCLUSIVE))
866 { 870 {
867 /* failed to bind => service must be running */ 871 /* failed to bind => service must be running */
868 GNUNET_free (unixpath); 872 GNUNET_free (unixpath);
@@ -912,7 +916,7 @@ GNUNET_CLIENT_service_test (const char *service,
912 { 916 {
913 if (GNUNET_OK != 917 if (GNUNET_OK !=
914 GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_in, 918 GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_in,
915 sizeof (s_in))) 919 sizeof (s_in), GNUNET_BIND_EXCLUSIVE))
916 { 920 {
917 /* failed to bind => service must be running */ 921 /* failed to bind => service must be running */
918 GNUNET_free (hostname); 922 GNUNET_free (hostname);
@@ -945,7 +949,7 @@ GNUNET_CLIENT_service_test (const char *service,
945 { 949 {
946 if (GNUNET_OK != 950 if (GNUNET_OK !=
947 GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_in6, 951 GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_in6,
948 sizeof (s_in6))) 952 sizeof (s_in6), GNUNET_BIND_EXCLUSIVE))
949 { 953 {
950 /* failed to bind => service must be running */ 954 /* failed to bind => service must be running */
951 GNUNET_free (hostname); 955 GNUNET_free (hostname);
diff --git a/src/util/connection.c b/src/util/connection.c
index c8d9919ea..3290abcfc 100644
--- a/src/util/connection.c
+++ b/src/util/connection.c
@@ -828,13 +828,22 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct
828#ifdef AF_UNIX 828#ifdef AF_UNIX
829 struct GNUNET_CONNECTION_Handle *connection; 829 struct GNUNET_CONNECTION_Handle *connection;
830 struct sockaddr_un *un; 830 struct sockaddr_un *un;
831 size_t slen;
831 832
832 GNUNET_assert (0 < strlen (unixpath)); /* sanity check */ 833 GNUNET_assert (0 < strlen (unixpath)); /* sanity check */
833 un = GNUNET_new (struct sockaddr_un); 834 un = GNUNET_new (struct sockaddr_un);
834 un->sun_family = AF_UNIX; 835 un->sun_family = AF_UNIX;
835 strncpy(un->sun_path, unixpath, sizeof(un->sun_path) - 1); 836 slen = strlen (unixpath);
837 if (slen >= sizeof (un->sun_path))
838 slen = sizeof (un->sun_path) - 1;
839 memcpy (un->sun_path, unixpath, slen);
840 un->sun_path[slen] = '\0';
841 slen = sizeof (struct sockaddr_un);
836#if HAVE_SOCKADDR_IN_SIN_LEN 842#if HAVE_SOCKADDR_IN_SIN_LEN
837 un->sun_len = (u_char) sizeof (struct sockaddr_un); 843 un->sun_len = (u_char) slen;
844#endif
845#if LINUX
846 un->sun_path[0] = '\0';
838#endif 847#endif
839 connection = GNUNET_new (struct GNUNET_CONNECTION_Handle); 848 connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
840 connection->cfg = cfg; 849 connection->cfg = cfg;
@@ -843,7 +852,7 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct
843 connection->port = 0; 852 connection->port = 0;
844 connection->hostname = NULL; 853 connection->hostname = NULL;
845 connection->addr = (struct sockaddr *) un; 854 connection->addr = (struct sockaddr *) un;
846 connection->addrlen = sizeof (struct sockaddr_un); 855 connection->addrlen = slen;
847 connection->sock = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0); 856 connection->sock = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0);
848 if (NULL == connection->sock) 857 if (NULL == connection->sock)
849 { 858 {
diff --git a/src/util/disk.c b/src/util/disk.c
index 34480e36a..066b0b99b 100644
--- a/src/util/disk.c
+++ b/src/util/disk.c
@@ -759,12 +759,13 @@ GNUNET_DISK_directory_create (const char *dir)
759 759
760 760
761/** 761/**
762 * Create the directory structure for storing a file. 762 * Create the directory structure for storing
763 * a file.
763 * 764 *
764 * @param filename name of a file in the directory 765 * @param filename name of a file in the directory
765 * @returns #GNUNET_OK on success, 766 * @returns GNUNET_OK on success,
766 * #GNUNET_SYSERR on failure, 767 * GNUNET_SYSERR on failure,
767 * #GNUNET_NO if the directory 768 * GNUNET_NO if the directory
768 * exists but is not writeable for us 769 * exists but is not writeable for us
769 */ 770 */
770int 771int
@@ -791,11 +792,10 @@ GNUNET_DISK_directory_create_for_file (const char *filename)
791 792
792/** 793/**
793 * Read the contents of a binary file into a buffer. 794 * Read the contents of a binary file into a buffer.
794 *
795 * @param h handle to an open file 795 * @param h handle to an open file
796 * @param result the buffer to write the result to 796 * @param result the buffer to write the result to
797 * @param len the maximum number of bytes to read 797 * @param len the maximum number of bytes to read
798 * @return the number of bytes read on success, #GNUNET_SYSERR on failure 798 * @return the number of bytes read on success, GNUNET_SYSERR on failure
799 */ 799 */
800ssize_t 800ssize_t
801GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle * h, void *result, 801GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle * h, void *result,
diff --git a/src/util/network.c b/src/util/network.c
index 793290b45..c0b977368 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -87,9 +87,7 @@ GNUNET_NETWORK_test_pf (int pf)
87 { 87 {
88 if (EAFNOSUPPORT == errno) 88 if (EAFNOSUPPORT == errno)
89 return GNUNET_NO; 89 return GNUNET_NO;
90 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 90 fprintf (stderr, "Failed to create test socket: %s\n", STRERROR (errno));
91 "Failed to create test socket: %s\n",
92 STRERROR (errno));
93 return GNUNET_SYSERR; 91 return GNUNET_SYSERR;
94 } 92 }
95#if WINDOWS 93#if WINDOWS
@@ -385,18 +383,20 @@ GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc,
385 * @param desc socket to bind 383 * @param desc socket to bind
386 * @param address address to be bound 384 * @param address address to be bound
387 * @param address_len length of @a address 385 * @param address_len length of @a address
386 * @param flags flags affecting bind behaviour
388 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise 387 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
389 */ 388 */
390int 389int
391GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc, 390GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc,
392 const struct sockaddr *address, 391 const struct sockaddr *address,
393 socklen_t address_len) 392 socklen_t address_len,
393 int flags)
394{ 394{
395 int ret; 395 int ret;
396 socklen_t bind_address_len = address_len; 396 socklen_t bind_address_len = address_len;
397 397
398#ifdef LINUX 398#ifdef LINUX
399 if (AF_UNIX == address->sa_family) 399 if (address->sa_family == AF_UNIX)
400 { 400 {
401 const struct sockaddr_un *address_un = (const struct sockaddr_un *)address; 401 const struct sockaddr_un *address_un = (const struct sockaddr_un *)address;
402 if (address_un->sun_path[0] == '\0') 402 if (address_un->sun_path[0] == '\0')
@@ -431,6 +431,16 @@ GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc,
431 LOG_STRERROR (GNUNET_ERROR_TYPE_DEBUG, "setsockopt"); 431 LOG_STRERROR (GNUNET_ERROR_TYPE_DEBUG, "setsockopt");
432 } 432 }
433#endif 433#endif
434#ifndef LINUX
435#ifndef MINGW
436 if (address->sa_family == AF_UNIX && (flags & GNUNET_BIND_EXCLUSIVE) == 0)
437 {
438 const struct sockaddr_un *un = (const struct sockaddr_un *) address;
439
440 (void) unlink (un->sun_path);
441 }
442#endif
443#endif
434 ret = bind (desc->fd, address, bind_address_len); 444 ret = bind (desc->fd, address, bind_address_len);
435#ifdef MINGW 445#ifdef MINGW
436 if (SOCKET_ERROR == ret) 446 if (SOCKET_ERROR == ret)
@@ -439,10 +449,12 @@ GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc,
439 if (ret != 0) 449 if (ret != 0)
440 return GNUNET_SYSERR; 450 return GNUNET_SYSERR;
441#ifndef MINGW 451#ifndef MINGW
452#ifndef LINUX
442 desc->addr = GNUNET_malloc (address_len); 453 desc->addr = GNUNET_malloc (address_len);
443 memcpy (desc->addr, address, address_len); 454 memcpy (desc->addr, address, address_len);
444 desc->addrlen = address_len; 455 desc->addrlen = address_len;
445#endif 456#endif
457#endif
446 return GNUNET_OK; 458 return GNUNET_OK;
447} 459}
448 460
@@ -471,17 +483,17 @@ GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc)
471#else 483#else
472 ret = close (desc->fd); 484 ret = close (desc->fd);
473#endif 485#endif
486#ifndef LINUX
474#ifndef MINGW 487#ifndef MINGW
475 if ((desc->af == AF_UNIX) && (NULL != desc->addr)) 488 if ((desc->af == AF_UNIX) && (NULL != desc->addr))
476 { 489 {
477 const struct sockaddr_un *un = (const struct sockaddr_un *) desc->addr; 490 const struct sockaddr_un *un = (const struct sockaddr_un *) desc->addr;
478 491
479 if (0 != unlink (un->sun_path)) 492 if (0 != unlink (un->sun_path))
480 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, 493 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "unlink", un->sun_path);
481 "unlink",
482 un->sun_path);
483 } 494 }
484#endif 495#endif
496#endif
485 GNUNET_NETWORK_socket_free_memory_only_ (desc); 497 GNUNET_NETWORK_socket_free_memory_only_ (desc);
486 return (ret == 0) ? GNUNET_OK : GNUNET_SYSERR; 498 return (ret == 0) ? GNUNET_OK : GNUNET_SYSERR;
487} 499}
diff --git a/src/util/resolver.conf.in b/src/util/resolver.conf.in
index 005082ea5..cccb60c2f 100644
--- a/src/util/resolver.conf.in
+++ b/src/util/resolver.conf.in
@@ -6,7 +6,7 @@ HOME = $SERVICEHOME
6BINARY = gnunet-service-resolver 6BINARY = gnunet-service-resolver
7ACCEPT_FROM = 127.0.0.1; 7ACCEPT_FROM = 127.0.0.1;
8ACCEPT_FROM6 = ::1; 8ACCEPT_FROM6 = ::1;
9UNIXPATH = $SERVICEHOME/gnunet-service-resolver.sock 9UNIXPATH = /tmp/gnunet-service-resolver.sock
10UNIX_MATCH_UID = NO 10UNIX_MATCH_UID = NO
11UNIX_MATCH_GID = NO 11UNIX_MATCH_GID = NO
12# DISABLE_SOCKET_FORWARDING = NO 12# DISABLE_SOCKET_FORWARDING = NO
diff --git a/src/util/server.c b/src/util/server.c
index 4df8fd83d..9e88992ca 100644
--- a/src/util/server.c
+++ b/src/util/server.c
@@ -469,7 +469,7 @@ open_listen_socket (const struct sockaddr *serverAddr, socklen_t socklen)
469 return NULL; 469 return NULL;
470 } 470 }
471 /* bind the socket */ 471 /* bind the socket */
472 if (GNUNET_OK != GNUNET_NETWORK_socket_bind (sock, serverAddr, socklen)) 472 if (GNUNET_OK != GNUNET_NETWORK_socket_bind (sock, serverAddr, socklen, 0))
473 { 473 {
474 eno = errno; 474 eno = errno;
475 if (EADDRINUSE != errno) 475 if (EADDRINUSE != errno)
diff --git a/src/util/service.c b/src/util/service.c
index 489dd2e55..b91be9664 100644
--- a/src/util/service.c
+++ b/src/util/service.c
@@ -841,15 +841,24 @@ add_unixpath (struct sockaddr **saddrs, socklen_t * saddrlens,
841{ 841{
842#ifdef AF_UNIX 842#ifdef AF_UNIX
843 struct sockaddr_un *un; 843 struct sockaddr_un *un;
844 size_t slen;
844 845
845 un = GNUNET_malloc (sizeof (struct sockaddr_un)); 846 un = GNUNET_malloc (sizeof (struct sockaddr_un));
846 un->sun_family = AF_UNIX; 847 un->sun_family = AF_UNIX;
847 strncpy (un->sun_path, unixpath, sizeof (un->sun_path) - 1); 848 slen = strlen (unixpath) + 1;
849 if (slen >= sizeof (un->sun_path))
850 slen = sizeof (un->sun_path) - 1;
851 memcpy (un->sun_path, unixpath, slen);
852 un->sun_path[slen] = '\0';
853 slen = sizeof (struct sockaddr_un);
854#if LINUX
855 un->sun_path[0] = '\0';
856#endif
848#if HAVE_SOCKADDR_IN_SIN_LEN 857#if HAVE_SOCKADDR_IN_SIN_LEN
849 un->sun_len = (u_char) sizeof (struct sockaddr_un); 858 un->sun_len = (u_char) slen;
850#endif 859#endif
851 *saddrs = (struct sockaddr *) un; 860 *saddrs = (struct sockaddr *) un;
852 *saddrlens = sizeof (struct sockaddr_un); 861 *saddrlens = slen;
853#else 862#else
854 /* this function should never be called 863 /* this function should never be called
855 * unless AF_UNIX is defined! */ 864 * unless AF_UNIX is defined! */
@@ -971,8 +980,8 @@ GNUNET_SERVICE_get_server_addresses (const char *service_name,
971 if ((GNUNET_YES == 980 if ((GNUNET_YES ==
972 GNUNET_CONFIGURATION_have_value (cfg, service_name, "UNIXPATH")) && 981 GNUNET_CONFIGURATION_have_value (cfg, service_name, "UNIXPATH")) &&
973 (GNUNET_OK == 982 (GNUNET_OK ==
974 GNUNET_CONFIGURATION_get_value_filename (cfg, service_name, "UNIXPATH", 983 GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "UNIXPATH",
975 &unixpath)) && 984 &unixpath)) &&
976 (0 < strlen (unixpath))) 985 (0 < strlen (unixpath)))
977 { 986 {
978 /* probe UNIX support */ 987 /* probe UNIX support */
@@ -987,11 +996,6 @@ GNUNET_SERVICE_get_server_addresses (const char *service_name,
987 LOG (GNUNET_ERROR_TYPE_INFO, 996 LOG (GNUNET_ERROR_TYPE_INFO,
988 _("Using `%s' instead\n"), unixpath); 997 _("Using `%s' instead\n"), unixpath);
989 } 998 }
990 if (GNUNET_OK !=
991 GNUNET_DISK_directory_create_for_file (unixpath))
992 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
993 "mkdir",
994 unixpath);
995 } 999 }
996 if (NULL != unixpath) 1000 if (NULL != unixpath)
997 { 1001 {
diff --git a/src/util/test_connection.c b/src/util/test_connection.c
index 6644623d4..1ba20498f 100644
--- a/src/util/test_connection.c
+++ b/src/util/test_connection.c
@@ -65,9 +65,9 @@ open_listen_socket ()
65 if (GNUNET_NETWORK_socket_setsockopt 65 if (GNUNET_NETWORK_socket_setsockopt
66 (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) 66 (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK)
67 GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); 67 GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt");
68 GNUNET_assert (GNUNET_OK == 68 GNUNET_assert (GNUNET_NETWORK_socket_bind
69 GNUNET_NETWORK_socket_bind (desc, (const struct sockaddr *) &sa, 69 (desc, (const struct sockaddr *) &sa,
70 sizeof (sa))); 70 sizeof (sa), 0) == GNUNET_OK);
71 GNUNET_NETWORK_socket_listen (desc, 5); 71 GNUNET_NETWORK_socket_listen (desc, 5);
72 return desc; 72 return desc;
73} 73}
diff --git a/src/util/test_connection_addressing.c b/src/util/test_connection_addressing.c
index e5c8edeeb..eeb610dd1 100644
--- a/src/util/test_connection_addressing.c
+++ b/src/util/test_connection_addressing.c
@@ -68,7 +68,7 @@ open_listen_socket ()
68 GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); 68 GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt");
69 if (GNUNET_OK != 69 if (GNUNET_OK !=
70 GNUNET_NETWORK_socket_bind (desc, (const struct sockaddr *) &sa, 70 GNUNET_NETWORK_socket_bind (desc, (const struct sockaddr *) &sa,
71 sizeof (sa))) 71 sizeof (sa), 0))
72 { 72 {
73 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 73 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
74 "bind"); 74 "bind");
diff --git a/src/util/test_connection_receive_cancel.c b/src/util/test_connection_receive_cancel.c
index c61272a57..99905e232 100644
--- a/src/util/test_connection_receive_cancel.c
+++ b/src/util/test_connection_receive_cancel.c
@@ -64,9 +64,9 @@ open_listen_socket ()
64 if (GNUNET_NETWORK_socket_setsockopt 64 if (GNUNET_NETWORK_socket_setsockopt
65 (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) 65 (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK)
66 GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); 66 GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt");
67 GNUNET_assert (GNUNET_OK == 67 GNUNET_assert (GNUNET_NETWORK_socket_bind
68 GNUNET_NETWORK_socket_bind (desc, (const struct sockaddr *) &sa, 68 (desc, (const struct sockaddr *) &sa,
69 sizeof (sa))); 69 sizeof (sa), 0) == GNUNET_OK);
70 GNUNET_NETWORK_socket_listen (desc, 5); 70 GNUNET_NETWORK_socket_listen (desc, 5);
71 return desc; 71 return desc;
72} 72}
diff --git a/src/util/test_connection_timeout.c b/src/util/test_connection_timeout.c
index 7241bbfae..6608e18db 100644
--- a/src/util/test_connection_timeout.c
+++ b/src/util/test_connection_timeout.c
@@ -61,9 +61,9 @@ open_listen_socket ()
61 if (GNUNET_NETWORK_socket_setsockopt 61 if (GNUNET_NETWORK_socket_setsockopt
62 (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) 62 (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK)
63 GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); 63 GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt");
64 GNUNET_assert (GNUNET_OK == 64 GNUNET_assert (GNUNET_NETWORK_socket_bind
65 GNUNET_NETWORK_socket_bind (desc, (const struct sockaddr *) &sa, 65 (desc, (const struct sockaddr *) &sa,
66 sizeof (sa))); 66 sizeof (sa), 0) == GNUNET_OK);
67 GNUNET_NETWORK_socket_listen (desc, 5); 67 GNUNET_NETWORK_socket_listen (desc, 5);
68 return desc; 68 return desc;
69} 69}
diff --git a/src/util/test_server_with_client_unix.c b/src/util/test_server_with_client_unix.c
index a4e0ffe5d..57a67d3f4 100644
--- a/src/util/test_server_with_client_unix.c
+++ b/src/util/test_server_with_client_unix.c
@@ -134,15 +134,20 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
134{ 134{
135 struct sockaddr_un un; 135 struct sockaddr_un un;
136 const char *unixpath = "/tmp/testsock"; 136 const char *unixpath = "/tmp/testsock";
137 size_t slen = strlen (unixpath);
137 struct sockaddr *sap[2]; 138 struct sockaddr *sap[2];
138 socklen_t slens[2]; 139 socklen_t slens[2];
139 140
140 memset (&un, 0, sizeof (un)); 141 memset (&un, 0, sizeof (un));
141 un.sun_family = AF_UNIX; 142 un.sun_family = AF_UNIX;
142 strncpy(un.sun_path, unixpath, sizeof (un.sun_path) - 1); 143 memcpy (un.sun_path, unixpath, slen);
144 un.sun_path[slen] = '\0';
143#if HAVE_SOCKADDR_IN_SIN_LEN 145#if HAVE_SOCKADDR_IN_SIN_LEN
144 un.sun_len = (u_char) sizeof (un); 146 un.sun_len = (u_char) sizeof (un);
145#endif 147#endif
148#if LINUX
149 un.sun_path[0] = '\0';
150#endif
146 151
147 sap[0] = (struct sockaddr *) &un; 152 sap[0] = (struct sockaddr *) &un;
148 slens[0] = sizeof (un); 153 slens[0] = sizeof (un);