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