aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
authorTimo Rothenpieler <timo@rothenpieler.org>2022-09-26 00:35:49 +0200
committerTimo Rothenpieler <timo@rothenpieler.org>2022-09-26 14:59:49 +0200
commit0eaa19a09a573ac9e1a77290b57557cd39860eff (patch)
tree485c23363b6bc6f6ca14ea2c50c5f4cc9d7c8675 /src/libutil
parent72d2415486f00a610e41f10110ff2521b1d6bcbd (diff)
downloadrspamd-0eaa19a09a573ac9e1a77290b57557cd39860eff.tar.gz
rspamd-0eaa19a09a573ac9e1a77290b57557cd39860eff.zip
[Fix] Bind AF_UNIX DGRAM client connection to annonymous address
Fixes #4278
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/addr.c13
1 files changed, 13 insertions, 0 deletions
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;