diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-09-27 09:49:39 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-09-27 09:49:39 +0000 |
commit | bcdae74167d2e1f9d8dd9b01fb368bf8bcc2287d (patch) | |
tree | b1f47d243e677d53de0c3503a1d5caf43dba073e /src/util/client.c | |
parent | dd22c2132e58ba4ac960337efc0f843c12f58780 (diff) | |
download | gnunet-bcdae74167d2e1f9d8dd9b01fb368bf8bcc2287d.tar.gz gnunet-bcdae74167d2e1f9d8dd9b01fb368bf8bcc2287d.zip |
-undo #29640, somehow causes problems
Diffstat (limited to 'src/util/client.c')
-rw-r--r-- | src/util/client.c | 30 |
1 files changed, 17 insertions, 13 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); |