diff options
author | grothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96> | 2011-05-25 21:41:52 +0000 |
---|---|---|
committer | grothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96> | 2011-05-25 21:41:52 +0000 |
commit | 263afe071a2ce9158b778eab08c1049ea4896139 (patch) | |
tree | 7a274ea3d3591fe59d724ca691fdc976d0175066 /src/util/service.c | |
parent | 465907aaa9146a952fe7c56ad6fa0d85c3dde050 (diff) |
set sxn_len on FreeBSD where required
git-svn-id: https://gnunet.org/svn/gnunet@15313 140774ce-b5e7-0310-ab8b-a85725594a96
Diffstat (limited to 'src/util/service.c')
-rw-r--r-- | src/util/service.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/util/service.c b/src/util/service.c index 834b27dd68..876b35265a 100644 --- a/src/util/service.c +++ b/src/util/service.c @@ -766,15 +766,13 @@ add_unixpath (struct sockaddr **saddrs, unixpath, slen); un->sun_path[slen] = '\0'; + slen = SUN_LEN (un); #if LINUX un->sun_path[0] = '\0'; - slen = sizeof (struct sockaddr_un); -#elif FREEBSD - slen += sizeof (sa_family_t) + 1 ; -#else - slen += sizeof (sa_family_t) ; #endif - +#if HAVE_SOCKADDR_IN_SIN_LEN + un->sun_len = (u_char) slen; +#endif *saddrs = (struct sockaddr*) un; *saddrlens = slen; #else @@ -909,6 +907,7 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, { /* probe UNIX support */ struct sockaddr_un s_un; + if (strlen(unixpath) >= sizeof(s_un.sun_path)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -923,8 +922,8 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, desc = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0); if (NULL == desc) { - if ((errno == ENOBUFS) || - (errno == ENOMEM) || (errno == ENFILE) || (errno == EACCES)) + if ( (errno == ENOBUFS) || + (errno == ENOMEM) || (errno == ENFILE) || (errno == EACCES)) { GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); GNUNET_free_non_null (hostname); |