From 0eaa19a09a573ac9e1a77290b57557cd39860eff Mon Sep 17 00:00:00 2001 From: Timo Rothenpieler Date: Mon, 26 Sep 2022 00:35:49 +0200 Subject: [PATCH] [Fix] Bind AF_UNIX DGRAM client connection to annonymous address Fixes #4278 --- src/libutil/addr.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/libutil/addr.c b/src/libutil/addr.c index 2e32d4bd1..4c3de70cf 100644 --- a/src/libutil/addr.c +++ b/src/libutil/addr.c @@ -1060,6 +1060,19 @@ rspamd_inet_address_connect (const rspamd_inet_addr_t *addr, gint type, if (addr->af == AF_UNIX) { sa = (const struct sockaddr *)&addr->u.un->addr; + + if (type == (int)SOCK_DGRAM) { + struct sockaddr ca; + + memset (&ca, 0, sizeof(ca)); + ca.sa_family = AF_UNIX; + + r = bind (fd, &ca, sizeof (sa_family_t)); + if (r == -1) { + msg_info ("unix socket client autobind failed: %s, '%s'", + addr->u.un->addr.sun_path, strerror (errno)); + } + } } else { sa = &addr->u.in.addr.sa; -- 2.39.5