diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/client.c | 23 | ||||
-rw-r--r-- | src/util/configuration.c | 10 | ||||
-rw-r--r-- | src/util/connection.c | 15 | ||||
-rw-r--r-- | src/util/network.c | 28 | ||||
-rw-r--r-- | src/util/server.c | 2 | ||||
-rw-r--r-- | src/util/service.c | 20 | ||||
-rw-r--r-- | src/util/test_connection.c | 6 | ||||
-rw-r--r-- | src/util/test_connection_addressing.c | 2 | ||||
-rw-r--r-- | src/util/test_connection_receive_cancel.c | 6 | ||||
-rw-r--r-- | src/util/test_connection_timeout.c | 6 | ||||
-rw-r--r-- | src/util/test_server_with_client_unix.c | 7 |
11 files changed, 44 insertions, 81 deletions
diff --git a/src/util/client.c b/src/util/client.c index 0e8804158..825c8ec52 100644 --- a/src/util/client.c +++ b/src/util/client.c | |||
@@ -829,11 +829,12 @@ GNUNET_CLIENT_service_test (const char *service, | |||
829 | { | 829 | { |
830 | /* probe UNIX support */ | 830 | /* probe UNIX support */ |
831 | struct sockaddr_un s_un; | 831 | struct sockaddr_un s_un; |
832 | size_t slen; | ||
833 | char *unixpath; | 832 | char *unixpath; |
834 | 833 | ||
835 | unixpath = NULL; | 834 | unixpath = NULL; |
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? */ | 835 | if ((GNUNET_OK == |
836 | GNUNET_CONFIGURATION_get_value_filename (cfg, service, "UNIXPATH", &unixpath)) && | ||
837 | (0 < strlen (unixpath))) /* We have a non-NULL unixpath, does that mean it's valid? */ | ||
837 | { | 838 | { |
838 | if (strlen (unixpath) >= sizeof (s_un.sun_path)) | 839 | if (strlen (unixpath) >= sizeof (s_un.sun_path)) |
839 | { | 840 | { |
@@ -852,21 +853,13 @@ GNUNET_CLIENT_service_test (const char *service, | |||
852 | { | 853 | { |
853 | memset (&s_un, 0, sizeof (s_un)); | 854 | memset (&s_un, 0, sizeof (s_un)); |
854 | s_un.sun_family = AF_UNIX; | 855 | s_un.sun_family = AF_UNIX; |
855 | slen = strlen (unixpath) + 1; | 856 | strncpy (s_un.sun_path, unixpath, sizeof (s_un.sun_path) - 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 | ||
864 | #if HAVE_SOCKADDR_IN_SIN_LEN | 857 | #if HAVE_SOCKADDR_IN_SIN_LEN |
865 | s_un.sun_len = (u_char) slen; | 858 | s_un.sun_len = (u_char) sizeof (struct sockaddr_un); |
866 | #endif | 859 | #endif |
867 | if (GNUNET_OK != | 860 | if (GNUNET_OK != |
868 | GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_un, | 861 | GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_un, |
869 | slen, GNUNET_BIND_EXCLUSIVE)) | 862 | sizeof (struct sockaddr_un))) |
870 | { | 863 | { |
871 | /* failed to bind => service must be running */ | 864 | /* failed to bind => service must be running */ |
872 | GNUNET_free (unixpath); | 865 | GNUNET_free (unixpath); |
@@ -916,7 +909,7 @@ GNUNET_CLIENT_service_test (const char *service, | |||
916 | { | 909 | { |
917 | if (GNUNET_OK != | 910 | if (GNUNET_OK != |
918 | GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_in, | 911 | GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_in, |
919 | sizeof (s_in), GNUNET_BIND_EXCLUSIVE)) | 912 | sizeof (s_in))) |
920 | { | 913 | { |
921 | /* failed to bind => service must be running */ | 914 | /* failed to bind => service must be running */ |
922 | GNUNET_free (hostname); | 915 | GNUNET_free (hostname); |
@@ -949,7 +942,7 @@ GNUNET_CLIENT_service_test (const char *service, | |||
949 | { | 942 | { |
950 | if (GNUNET_OK != | 943 | if (GNUNET_OK != |
951 | GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_in6, | 944 | GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_in6, |
952 | sizeof (s_in6), GNUNET_BIND_EXCLUSIVE)) | 945 | sizeof (s_in6))) |
953 | { | 946 | { |
954 | /* failed to bind => service must be running */ | 947 | /* failed to bind => service must be running */ |
955 | GNUNET_free (hostname); | 948 | GNUNET_free (hostname); |
diff --git a/src/util/configuration.c b/src/util/configuration.c index d7076fac1..1e516b825 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c | |||
@@ -88,8 +88,8 @@ struct GNUNET_CONFIGURATION_Handle | |||
88 | 88 | ||
89 | /** | 89 | /** |
90 | * Modification indication since last save | 90 | * Modification indication since last save |
91 | * GNUNET_NO if clean, GNUNET_YES if dirty, | 91 | * #GNUNET_NO if clean, #GNUNET_YES if dirty, |
92 | * GNUNET_SYSERR on error (i.e. last save failed) | 92 | * #GNUNET_SYSERR on error (i.e. last save failed) |
93 | */ | 93 | */ |
94 | int dirty; | 94 | int dirty; |
95 | 95 | ||
@@ -142,10 +142,10 @@ GNUNET_CONFIGURATION_destroy (struct GNUNET_CONFIGURATION_Handle *cfg) | |||
142 | * @param cfg configuration to update | 142 | * @param cfg configuration to update |
143 | * @param mem the memory block of serialized configuration | 143 | * @param mem the memory block of serialized configuration |
144 | * @param size the size of the memory block | 144 | * @param size the size of the memory block |
145 | * @param allow_inline set to GNUNET_YES if we recursively load configuration | 145 | * @param allow_inline set to #GNUNET_YES if we recursively load configuration |
146 | * from inlined configurations; GNUNET_NO if not and raise warnings | 146 | * from inlined configurations; #GNUNET_NO if not and raise warnings |
147 | * when we come across them | 147 | * when we come across them |
148 | * @return GNUNET_OK on success, GNUNET_ERROR on error | 148 | * @return #GNUNET_OK on success, #GNUNET_ERROR on error |
149 | */ | 149 | */ |
150 | int | 150 | int |
151 | GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, | 151 | GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, |
diff --git a/src/util/connection.c b/src/util/connection.c index a429f2f7e..eeabebdf7 100644 --- a/src/util/connection.c +++ b/src/util/connection.c | |||
@@ -826,22 +826,13 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct | |||
826 | #ifdef AF_UNIX | 826 | #ifdef AF_UNIX |
827 | struct GNUNET_CONNECTION_Handle *connection; | 827 | struct GNUNET_CONNECTION_Handle *connection; |
828 | struct sockaddr_un *un; | 828 | struct sockaddr_un *un; |
829 | size_t slen; | ||
830 | 829 | ||
831 | GNUNET_assert (0 < strlen (unixpath)); /* sanity check */ | 830 | GNUNET_assert (0 < strlen (unixpath)); /* sanity check */ |
832 | un = GNUNET_new (struct sockaddr_un); | 831 | un = GNUNET_new (struct sockaddr_un); |
833 | un->sun_family = AF_UNIX; | 832 | un->sun_family = AF_UNIX; |
834 | slen = strlen (unixpath); | 833 | strncpy(un->sun_path, unixpath, sizeof(un->sun_path) - 1); |
835 | if (slen >= sizeof (un->sun_path)) | ||
836 | slen = sizeof (un->sun_path) - 1; | ||
837 | memcpy (un->sun_path, unixpath, slen); | ||
838 | un->sun_path[slen] = '\0'; | ||
839 | slen = sizeof (struct sockaddr_un); | ||
840 | #if HAVE_SOCKADDR_IN_SIN_LEN | 834 | #if HAVE_SOCKADDR_IN_SIN_LEN |
841 | un->sun_len = (u_char) slen; | 835 | un->sun_len = (u_char) sizeof (struct sockaddr_un); |
842 | #endif | ||
843 | #if LINUX | ||
844 | un->sun_path[0] = '\0'; | ||
845 | #endif | 836 | #endif |
846 | connection = GNUNET_new (struct GNUNET_CONNECTION_Handle); | 837 | connection = GNUNET_new (struct GNUNET_CONNECTION_Handle); |
847 | connection->cfg = cfg; | 838 | connection->cfg = cfg; |
@@ -850,7 +841,7 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct | |||
850 | connection->port = 0; | 841 | connection->port = 0; |
851 | connection->hostname = NULL; | 842 | connection->hostname = NULL; |
852 | connection->addr = (struct sockaddr *) un; | 843 | connection->addr = (struct sockaddr *) un; |
853 | connection->addrlen = slen; | 844 | connection->addrlen = sizeof (struct sockaddr_un); |
854 | connection->sock = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0); | 845 | connection->sock = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0); |
855 | if (NULL == connection->sock) | 846 | if (NULL == connection->sock) |
856 | { | 847 | { |
diff --git a/src/util/network.c b/src/util/network.c index a921998e9..7a4b2a0b3 100644 --- a/src/util/network.c +++ b/src/util/network.c | |||
@@ -87,7 +87,9 @@ 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 | fprintf (stderr, "Failed to create test socket: %s\n", STRERROR (errno)); | 90 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
91 | "Failed to create test socket: %s\n", | ||
92 | STRERROR (errno)); | ||
91 | return GNUNET_SYSERR; | 93 | return GNUNET_SYSERR; |
92 | } | 94 | } |
93 | #if WINDOWS | 95 | #if WINDOWS |
@@ -383,20 +385,18 @@ GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc, | |||
383 | * @param desc socket to bind | 385 | * @param desc socket to bind |
384 | * @param address address to be bound | 386 | * @param address address to be bound |
385 | * @param address_len length of @a address | 387 | * @param address_len length of @a address |
386 | * @param flags flags affecting bind behaviour | ||
387 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 388 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
388 | */ | 389 | */ |
389 | int | 390 | int |
390 | GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc, | 391 | GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc, |
391 | const struct sockaddr *address, | 392 | const struct sockaddr *address, |
392 | socklen_t address_len, | 393 | 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 (address->sa_family == AF_UNIX) | 399 | if (AF_UNIX == address->sa_family) |
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,16 +431,6 @@ 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 | ||
444 | ret = bind (desc->fd, address, bind_address_len); | 434 | ret = bind (desc->fd, address, bind_address_len); |
445 | #ifdef MINGW | 435 | #ifdef MINGW |
446 | if (SOCKET_ERROR == ret) | 436 | if (SOCKET_ERROR == ret) |
@@ -449,12 +439,10 @@ GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc, | |||
449 | if (ret != 0) | 439 | if (ret != 0) |
450 | return GNUNET_SYSERR; | 440 | return GNUNET_SYSERR; |
451 | #ifndef MINGW | 441 | #ifndef MINGW |
452 | #ifndef LINUX | ||
453 | desc->addr = GNUNET_malloc (address_len); | 442 | desc->addr = GNUNET_malloc (address_len); |
454 | memcpy (desc->addr, address, address_len); | 443 | memcpy (desc->addr, address, address_len); |
455 | desc->addrlen = address_len; | 444 | desc->addrlen = address_len; |
456 | #endif | 445 | #endif |
457 | #endif | ||
458 | return GNUNET_OK; | 446 | return GNUNET_OK; |
459 | } | 447 | } |
460 | 448 | ||
@@ -483,17 +471,17 @@ GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc) | |||
483 | #else | 471 | #else |
484 | ret = close (desc->fd); | 472 | ret = close (desc->fd); |
485 | #endif | 473 | #endif |
486 | #ifndef LINUX | ||
487 | #ifndef MINGW | 474 | #ifndef MINGW |
488 | if ((desc->af == AF_UNIX) && (NULL != desc->addr)) | 475 | if ((desc->af == AF_UNIX) && (NULL != desc->addr)) |
489 | { | 476 | { |
490 | const struct sockaddr_un *un = (const struct sockaddr_un *) desc->addr; | 477 | const struct sockaddr_un *un = (const struct sockaddr_un *) desc->addr; |
491 | 478 | ||
492 | if (0 != unlink (un->sun_path)) | 479 | if (0 != unlink (un->sun_path)) |
493 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "unlink", un->sun_path); | 480 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, |
481 | "unlink", | ||
482 | un->sun_path); | ||
494 | } | 483 | } |
495 | #endif | 484 | #endif |
496 | #endif | ||
497 | GNUNET_NETWORK_socket_free_memory_only_ (desc); | 485 | GNUNET_NETWORK_socket_free_memory_only_ (desc); |
498 | return (ret == 0) ? GNUNET_OK : GNUNET_SYSERR; | 486 | return (ret == 0) ? GNUNET_OK : GNUNET_SYSERR; |
499 | } | 487 | } |
diff --git a/src/util/server.c b/src/util/server.c index e00b2ffb8..397e32f8c 100644 --- a/src/util/server.c +++ b/src/util/server.c | |||
@@ -468,7 +468,7 @@ open_listen_socket (const struct sockaddr *serverAddr, socklen_t socklen) | |||
468 | return NULL; | 468 | return NULL; |
469 | } | 469 | } |
470 | /* bind the socket */ | 470 | /* bind the socket */ |
471 | if (GNUNET_OK != GNUNET_NETWORK_socket_bind (sock, serverAddr, socklen, 0)) | 471 | if (GNUNET_OK != GNUNET_NETWORK_socket_bind (sock, serverAddr, socklen)) |
472 | { | 472 | { |
473 | eno = errno; | 473 | eno = errno; |
474 | if (EADDRINUSE != errno) | 474 | if (EADDRINUSE != errno) |
diff --git a/src/util/service.c b/src/util/service.c index eb3a84221..b8975f418 100644 --- a/src/util/service.c +++ b/src/util/service.c | |||
@@ -834,24 +834,15 @@ add_unixpath (struct sockaddr **saddrs, socklen_t * saddrlens, | |||
834 | { | 834 | { |
835 | #ifdef AF_UNIX | 835 | #ifdef AF_UNIX |
836 | struct sockaddr_un *un; | 836 | struct sockaddr_un *un; |
837 | size_t slen; | ||
838 | 837 | ||
839 | un = GNUNET_malloc (sizeof (struct sockaddr_un)); | 838 | un = GNUNET_malloc (sizeof (struct sockaddr_un)); |
840 | un->sun_family = AF_UNIX; | 839 | un->sun_family = AF_UNIX; |
841 | slen = strlen (unixpath) + 1; | 840 | strncpy (un->sun_path, unixpath, sizeof (un->sun_path) - 1); |
842 | if (slen >= sizeof (un->sun_path)) | ||
843 | slen = sizeof (un->sun_path) - 1; | ||
844 | memcpy (un->sun_path, unixpath, slen); | ||
845 | un->sun_path[slen] = '\0'; | ||
846 | slen = sizeof (struct sockaddr_un); | ||
847 | #if LINUX | ||
848 | un->sun_path[0] = '\0'; | ||
849 | #endif | ||
850 | #if HAVE_SOCKADDR_IN_SIN_LEN | 841 | #if HAVE_SOCKADDR_IN_SIN_LEN |
851 | un->sun_len = (u_char) slen; | 842 | un->sun_len = (u_char) sizeof (struct sockaddr_un); |
852 | #endif | 843 | #endif |
853 | *saddrs = (struct sockaddr *) un; | 844 | *saddrs = (struct sockaddr *) un; |
854 | *saddrlens = slen; | 845 | *saddrlens = sizeof (struct sockaddr_un); |
855 | #else | 846 | #else |
856 | /* this function should never be called | 847 | /* this function should never be called |
857 | * unless AF_UNIX is defined! */ | 848 | * unless AF_UNIX is defined! */ |
@@ -989,6 +980,11 @@ GNUNET_SERVICE_get_server_addresses (const char *service_name, | |||
989 | LOG (GNUNET_ERROR_TYPE_INFO, | 980 | LOG (GNUNET_ERROR_TYPE_INFO, |
990 | _("Using `%s' instead\n"), unixpath); | 981 | _("Using `%s' instead\n"), unixpath); |
991 | } | 982 | } |
983 | if (GNUNET_OK != | ||
984 | GNUNET_DISK_directory_create_for_file (unixpath)) | ||
985 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | ||
986 | "mkdir", | ||
987 | unixpath); | ||
992 | } | 988 | } |
993 | if (NULL != unixpath) | 989 | if (NULL != unixpath) |
994 | { | 990 | { |
diff --git a/src/util/test_connection.c b/src/util/test_connection.c index 124f3c9d3..13c800995 100644 --- a/src/util/test_connection.c +++ b/src/util/test_connection.c | |||
@@ -62,9 +62,9 @@ open_listen_socket () | |||
62 | if (GNUNET_NETWORK_socket_setsockopt | 62 | if (GNUNET_NETWORK_socket_setsockopt |
63 | (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) | 63 | (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) |
64 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); | 64 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); |
65 | GNUNET_assert (GNUNET_NETWORK_socket_bind | 65 | GNUNET_assert (GNUNET_OK == |
66 | (desc, (const struct sockaddr *) &sa, | 66 | GNUNET_NETWORK_socket_bind (desc, (const struct sockaddr *) &sa, |
67 | sizeof (sa), 0) == GNUNET_OK); | 67 | sizeof (sa))); |
68 | GNUNET_NETWORK_socket_listen (desc, 5); | 68 | GNUNET_NETWORK_socket_listen (desc, 5); |
69 | return desc; | 69 | return desc; |
70 | } | 70 | } |
diff --git a/src/util/test_connection_addressing.c b/src/util/test_connection_addressing.c index ea6acdd53..adab28d40 100644 --- a/src/util/test_connection_addressing.c +++ b/src/util/test_connection_addressing.c | |||
@@ -65,7 +65,7 @@ open_listen_socket () | |||
65 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); | 65 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); |
66 | if (GNUNET_OK != | 66 | if (GNUNET_OK != |
67 | GNUNET_NETWORK_socket_bind (desc, (const struct sockaddr *) &sa, | 67 | GNUNET_NETWORK_socket_bind (desc, (const struct sockaddr *) &sa, |
68 | sizeof (sa), 0)) | 68 | sizeof (sa))) |
69 | { | 69 | { |
70 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 70 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
71 | "bind"); | 71 | "bind"); |
diff --git a/src/util/test_connection_receive_cancel.c b/src/util/test_connection_receive_cancel.c index e47712d3f..32a00fcfa 100644 --- a/src/util/test_connection_receive_cancel.c +++ b/src/util/test_connection_receive_cancel.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_NETWORK_socket_bind | 64 | GNUNET_assert (GNUNET_OK == |
65 | (desc, (const struct sockaddr *) &sa, | 65 | GNUNET_NETWORK_socket_bind (desc, (const struct sockaddr *) &sa, |
66 | sizeof (sa), 0) == GNUNET_OK); | 66 | sizeof (sa))); |
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_connection_timeout.c b/src/util/test_connection_timeout.c index 27170ed41..ec8057cf2 100644 --- a/src/util/test_connection_timeout.c +++ b/src/util/test_connection_timeout.c | |||
@@ -58,9 +58,9 @@ open_listen_socket () | |||
58 | if (GNUNET_NETWORK_socket_setsockopt | 58 | if (GNUNET_NETWORK_socket_setsockopt |
59 | (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) | 59 | (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) |
60 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); | 60 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); |
61 | GNUNET_assert (GNUNET_NETWORK_socket_bind | 61 | GNUNET_assert (GNUNET_OK == |
62 | (desc, (const struct sockaddr *) &sa, | 62 | GNUNET_NETWORK_socket_bind (desc, (const struct sockaddr *) &sa, |
63 | sizeof (sa), 0) == GNUNET_OK); | 63 | sizeof (sa))); |
64 | GNUNET_NETWORK_socket_listen (desc, 5); | 64 | GNUNET_NETWORK_socket_listen (desc, 5); |
65 | return desc; | 65 | return desc; |
66 | } | 66 | } |
diff --git a/src/util/test_server_with_client_unix.c b/src/util/test_server_with_client_unix.c index 30e993411..49b70478d 100644 --- a/src/util/test_server_with_client_unix.c +++ b/src/util/test_server_with_client_unix.c | |||
@@ -130,20 +130,15 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
130 | { | 130 | { |
131 | struct sockaddr_un un; | 131 | struct sockaddr_un un; |
132 | const char *unixpath = "/tmp/testsock"; | 132 | const char *unixpath = "/tmp/testsock"; |
133 | size_t slen = strlen (unixpath); | ||
134 | struct sockaddr *sap[2]; | 133 | struct sockaddr *sap[2]; |
135 | socklen_t slens[2]; | 134 | socklen_t slens[2]; |
136 | 135 | ||
137 | memset (&un, 0, sizeof (un)); | 136 | memset (&un, 0, sizeof (un)); |
138 | un.sun_family = AF_UNIX; | 137 | un.sun_family = AF_UNIX; |
139 | memcpy (un.sun_path, unixpath, slen); | 138 | strncpy(un.sun_path, unixpath, sizeof (un.sun_path) - 1); |
140 | un.sun_path[slen] = '\0'; | ||
141 | #if HAVE_SOCKADDR_IN_SIN_LEN | 139 | #if HAVE_SOCKADDR_IN_SIN_LEN |
142 | un.sun_len = (u_char) sizeof (un); | 140 | un.sun_len = (u_char) sizeof (un); |
143 | #endif | 141 | #endif |
144 | #if LINUX | ||
145 | un.sun_path[0] = '\0'; | ||
146 | #endif | ||
147 | 142 | ||
148 | sap[0] = (struct sockaddr *) &un; | 143 | sap[0] = (struct sockaddr *) &un; |
149 | slens[0] = sizeof (un); | 144 | slens[0] = sizeof (un); |