From: Timo Rothenpieler Date: Sun, 25 Sep 2022 22:35:49 +0000 (+0200) Subject: [Fix] Bind AF_UNIX DGRAM client connection to annonymous address X-Git-Tag: 3.3~3^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0eaa19a09a573ac9e1a77290b57557cd39860eff;p=rspamd.git [Fix] Bind AF_UNIX DGRAM client connection to annonymous address Fixes #4278 --- 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;