diff options
Diffstat (limited to 'src/util/client.c')
-rw-r--r-- | src/util/client.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/util/client.c b/src/util/client.c index 30c80bf03..64960f232 100644 --- a/src/util/client.c +++ b/src/util/client.c | |||
@@ -251,7 +251,9 @@ 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 == GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "UNIXPATH", &unixpath)) && | 254 | if ((GNUNET_OK == |
255 | GNUNET_CONFIGURATION_get_value_filename (cfg, service_name, | ||
256 | "UNIXPATH", &unixpath)) && | ||
255 | (0 < strlen (unixpath))) | 257 | (0 < strlen (unixpath))) |
256 | { | 258 | { |
257 | /* We have a non-NULL unixpath, need to validate it */ | 259 | /* We have a non-NULL unixpath, need to validate it */ |
@@ -299,7 +301,8 @@ test_service_configuration (const char *service_name, | |||
299 | #if AF_UNIX | 301 | #if AF_UNIX |
300 | char *unixpath = NULL; | 302 | char *unixpath = NULL; |
301 | 303 | ||
302 | if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "UNIXPATH", &unixpath)) && | 304 | if ((GNUNET_OK == |
305 | GNUNET_CONFIGURATION_get_value_filename (cfg, service_name, "UNIXPATH", &unixpath)) && | ||
303 | (0 < strlen (unixpath))) | 306 | (0 < strlen (unixpath))) |
304 | ret = GNUNET_OK; | 307 | ret = GNUNET_OK; |
305 | GNUNET_free_non_null (unixpath); | 308 | GNUNET_free_non_null (unixpath); |
@@ -829,11 +832,12 @@ GNUNET_CLIENT_service_test (const char *service, | |||
829 | { | 832 | { |
830 | /* probe UNIX support */ | 833 | /* probe UNIX support */ |
831 | struct sockaddr_un s_un; | 834 | struct sockaddr_un s_un; |
832 | size_t slen; | ||
833 | char *unixpath; | 835 | char *unixpath; |
834 | 836 | ||
835 | unixpath = NULL; | 837 | 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? */ | 838 | if ((GNUNET_OK == |
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? */ | ||
837 | { | 841 | { |
838 | if (strlen (unixpath) >= sizeof (s_un.sun_path)) | 842 | if (strlen (unixpath) >= sizeof (s_un.sun_path)) |
839 | { | 843 | { |
@@ -852,21 +856,13 @@ GNUNET_CLIENT_service_test (const char *service, | |||
852 | { | 856 | { |
853 | memset (&s_un, 0, sizeof (s_un)); | 857 | memset (&s_un, 0, sizeof (s_un)); |
854 | s_un.sun_family = AF_UNIX; | 858 | s_un.sun_family = AF_UNIX; |
855 | slen = strlen (unixpath) + 1; | 859 | 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 | 860 | #if HAVE_SOCKADDR_IN_SIN_LEN |
865 | s_un.sun_len = (u_char) slen; | 861 | s_un.sun_len = (u_char) sizeof (struct sockaddr_un); |
866 | #endif | 862 | #endif |
867 | if (GNUNET_OK != | 863 | if (GNUNET_OK != |
868 | GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_un, | 864 | GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_un, |
869 | slen, GNUNET_BIND_EXCLUSIVE)) | 865 | sizeof (struct sockaddr_un))) |
870 | { | 866 | { |
871 | /* failed to bind => service must be running */ | 867 | /* failed to bind => service must be running */ |
872 | GNUNET_free (unixpath); | 868 | GNUNET_free (unixpath); |
@@ -916,7 +912,7 @@ GNUNET_CLIENT_service_test (const char *service, | |||
916 | { | 912 | { |
917 | if (GNUNET_OK != | 913 | if (GNUNET_OK != |
918 | GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_in, | 914 | GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_in, |
919 | sizeof (s_in), GNUNET_BIND_EXCLUSIVE)) | 915 | sizeof (s_in))) |
920 | { | 916 | { |
921 | /* failed to bind => service must be running */ | 917 | /* failed to bind => service must be running */ |
922 | GNUNET_free (hostname); | 918 | GNUNET_free (hostname); |
@@ -949,7 +945,7 @@ GNUNET_CLIENT_service_test (const char *service, | |||
949 | { | 945 | { |
950 | if (GNUNET_OK != | 946 | if (GNUNET_OK != |
951 | GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_in6, | 947 | GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_in6, |
952 | sizeof (s_in6), GNUNET_BIND_EXCLUSIVE)) | 948 | sizeof (s_in6))) |
953 | { | 949 | { |
954 | /* failed to bind => service must be running */ | 950 | /* failed to bind => service must be running */ |
955 | GNUNET_free (hostname); | 951 | GNUNET_free (hostname); |