diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-09 18:01:16 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-09 18:01:16 +0000 |
commit | 25e37143ca6ddc3ea7d3c2e3fd7c66002a45e060 (patch) | |
tree | 8796fd0e148c6914897d6c53d25c6327b5a8263b /src/util/connection.c | |
parent | 0904af031c4f1411419b3047f893e0672957d146 (diff) | |
download | gnunet-25e37143ca6ddc3ea7d3c2e3fd7c66002a45e060.tar.gz gnunet-25e37143ca6ddc3ea7d3c2e3fd7c66002a45e060.zip |
-switching (again) to named sockets, see #2887
Diffstat (limited to 'src/util/connection.c')
-rw-r--r-- | src/util/connection.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/src/util/connection.c b/src/util/connection.c index a429f2f7e..eeabebdf7 100644 --- a/src/util/connection.c +++ b/src/util/connection.c | |||
@@ -826,22 +826,13 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct | |||
826 | #ifdef AF_UNIX | 826 | #ifdef AF_UNIX |
827 | struct GNUNET_CONNECTION_Handle *connection; | 827 | struct GNUNET_CONNECTION_Handle *connection; |
828 | struct sockaddr_un *un; | 828 | struct sockaddr_un *un; |
829 | size_t slen; | ||
830 | 829 | ||
831 | GNUNET_assert (0 < strlen (unixpath)); /* sanity check */ | 830 | GNUNET_assert (0 < strlen (unixpath)); /* sanity check */ |
832 | un = GNUNET_new (struct sockaddr_un); | 831 | un = GNUNET_new (struct sockaddr_un); |
833 | un->sun_family = AF_UNIX; | 832 | un->sun_family = AF_UNIX; |
834 | slen = strlen (unixpath); | 833 | strncpy(un->sun_path, unixpath, sizeof(un->sun_path) - 1); |
835 | if (slen >= sizeof (un->sun_path)) | ||
836 | slen = sizeof (un->sun_path) - 1; | ||
837 | memcpy (un->sun_path, unixpath, slen); | ||
838 | un->sun_path[slen] = '\0'; | ||
839 | slen = sizeof (struct sockaddr_un); | ||
840 | #if HAVE_SOCKADDR_IN_SIN_LEN | 834 | #if HAVE_SOCKADDR_IN_SIN_LEN |
841 | un->sun_len = (u_char) slen; | 835 | un->sun_len = (u_char) sizeof (struct sockaddr_un); |
842 | #endif | ||
843 | #if LINUX | ||
844 | un->sun_path[0] = '\0'; | ||
845 | #endif | 836 | #endif |
846 | connection = GNUNET_new (struct GNUNET_CONNECTION_Handle); | 837 | connection = GNUNET_new (struct GNUNET_CONNECTION_Handle); |
847 | connection->cfg = cfg; | 838 | connection->cfg = cfg; |
@@ -850,7 +841,7 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct | |||
850 | connection->port = 0; | 841 | connection->port = 0; |
851 | connection->hostname = NULL; | 842 | connection->hostname = NULL; |
852 | connection->addr = (struct sockaddr *) un; | 843 | connection->addr = (struct sockaddr *) un; |
853 | connection->addrlen = slen; | 844 | connection->addrlen = sizeof (struct sockaddr_un); |
854 | connection->sock = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0); | 845 | connection->sock = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0); |
855 | if (NULL == connection->sock) | 846 | if (NULL == connection->sock) |
856 | { | 847 | { |