aboutsummaryrefslogtreecommitdiffstats
path: root/src/util.c
diff options
context:
space:
mode:
authorcebka@lenovo-laptop <cebka@lenovo-laptop>2010-02-15 17:02:15 +0300
committercebka@lenovo-laptop <cebka@lenovo-laptop>2010-02-15 17:02:15 +0300
commit22b965e141130042802a6a92dfe2f8d34881344b (patch)
treec354889e39c7bf4794c763daaf9e311ecb0ce22c /src/util.c
parent341a236aa614d66bd76764e3eb315b6df0688ef5 (diff)
downloadrspamd-22b965e141130042802a6a92dfe2f8d34881344b.tar.gz
rspamd-22b965e141130042802a6a92dfe2f8d34881344b.zip
* Fix unix socket creation under FreeBSD (reported by Andrey Zverev)
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/util.c b/src/util.c
index b43da4322..c093ccc36 100644
--- a/src/util.c
+++ b/src/util.c
@@ -215,19 +215,17 @@ accept_from_socket (int listen_sock, struct sockaddr *addr, socklen_t * len)
int
make_unix_socket (const char *path, struct sockaddr_un *addr, gboolean is_server)
{
- size_t len = strlen (path);
int fd, s_error, r, optlen, serrno, on = 1;
- if (len > sizeof (addr->sun_path) - 1 || path == NULL)
+ if (path == NULL)
return -1;
-#ifdef FREEBSD
- addr->sun_len = sizeof (struct sockaddr_un);
-#endif
-
addr->sun_family = AF_UNIX;
- strncpy (addr->sun_path, path, len);
+ g_strlcpy (addr->sun_path, path, sizeof (addr->sun_path));
+#ifdef FREEBSD
+ addr->sun_len = SUN_LEN (addr);
+#endif
fd = socket (PF_LOCAL, SOCK_STREAM, 0);