aboutsummaryrefslogtreecommitdiff
path: root/src/util/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/client.c')
-rw-r--r--src/util/client.c23
1 files changed, 8 insertions, 15 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);