aboutsummaryrefslogtreecommitdiff
path: root/src/util/service.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/service.c')
-rw-r--r--src/util/service.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/util/service.c b/src/util/service.c
index b91be9664..489dd2e55 100644
--- a/src/util/service.c
+++ b/src/util/service.c
@@ -841,24 +841,15 @@ 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;
845 844
846 un = GNUNET_malloc (sizeof (struct sockaddr_un)); 845 un = GNUNET_malloc (sizeof (struct sockaddr_un));
847 un->sun_family = AF_UNIX; 846 un->sun_family = AF_UNIX;
848 slen = strlen (unixpath) + 1; 847 strncpy (un->sun_path, unixpath, sizeof (un->sun_path) - 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
857#if HAVE_SOCKADDR_IN_SIN_LEN 848#if HAVE_SOCKADDR_IN_SIN_LEN
858 un->sun_len = (u_char) slen; 849 un->sun_len = (u_char) sizeof (struct sockaddr_un);
859#endif 850#endif
860 *saddrs = (struct sockaddr *) un; 851 *saddrs = (struct sockaddr *) un;
861 *saddrlens = slen; 852 *saddrlens = sizeof (struct sockaddr_un);
862#else 853#else
863 /* this function should never be called 854 /* this function should never be called
864 * unless AF_UNIX is defined! */ 855 * unless AF_UNIX is defined! */
@@ -980,8 +971,8 @@ GNUNET_SERVICE_get_server_addresses (const char *service_name,
980 if ((GNUNET_YES == 971 if ((GNUNET_YES ==
981 GNUNET_CONFIGURATION_have_value (cfg, service_name, "UNIXPATH")) && 972 GNUNET_CONFIGURATION_have_value (cfg, service_name, "UNIXPATH")) &&
982 (GNUNET_OK == 973 (GNUNET_OK ==
983 GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "UNIXPATH", 974 GNUNET_CONFIGURATION_get_value_filename (cfg, service_name, "UNIXPATH",
984 &unixpath)) && 975 &unixpath)) &&
985 (0 < strlen (unixpath))) 976 (0 < strlen (unixpath)))
986 { 977 {
987 /* probe UNIX support */ 978 /* probe UNIX support */
@@ -996,6 +987,11 @@ GNUNET_SERVICE_get_server_addresses (const char *service_name,
996 LOG (GNUNET_ERROR_TYPE_INFO, 987 LOG (GNUNET_ERROR_TYPE_INFO,
997 _("Using `%s' instead\n"), unixpath); 988 _("Using `%s' instead\n"), unixpath);
998 } 989 }
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);
999 } 995 }
1000 if (NULL != unixpath) 996 if (NULL != unixpath)
1001 { 997 {