]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Bind AF_UNIX DGRAM client connection to annonymous address
authorTimo Rothenpieler <timo@rothenpieler.org>
Sun, 25 Sep 2022 22:35:49 +0000 (00:35 +0200)
committerTimo Rothenpieler <timo@rothenpieler.org>
Mon, 26 Sep 2022 12:59:49 +0000 (14:59 +0200)
Fixes #4278

src/libutil/addr.c

index 2e32d4bd106c2819638cfdf053b2457d1b63c3e9..4c3de70cfdf49e8f9c4b4155d4ff292e63c4140c 100644 (file)
@@ -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;