Hi,
I have a unbound forward zone configured on my router for my $DAYJOB.
The address associated with the zone is only accessible when the router
is connected to a VPN. If the VPN connection is absent, trying to
resolve any domain that must be handled by the zone crashes unbound.
Turns out there's a missing NULL check in comm_point_send_udp_msg().
The same routine already has `if (addr) {} else {}' branches so I guess
protecting the call to log_addr() using the same conditional is
reasonable.

Should this instead be upstreamed? Comments? OK?

Index: util/netevent.c
===================================================================
RCS file: /cvs/src/usr.sbin/unbound/util/netevent.c,v
retrieving revision 1.27
diff -u -p -r1.27 netevent.c
--- util/netevent.c     10 Dec 2020 21:44:58 -0000      1.27
+++ util/netevent.c     6 Jan 2021 09:03:59 -0000
@@ -379,8 +379,9 @@ comm_point_send_udp_msg(struct comm_poin
                if(!udp_send_errno_needs_log(addr, addrlen))
                        return 0;
                verbose(VERB_OPS, "sendto failed: %s", sock_strerror(errno));
-               log_addr(VERB_OPS, "remote address is", 
-                       (struct sockaddr_storage*)addr, addrlen);
+               if(addr)
+                       log_addr(VERB_OPS, "remote address is",
+                               (struct sockaddr_storage*)addr, addrlen);
                return 0;
        } else if((size_t)sent != sldns_buffer_remaining(packet)) {
                log_err("sent %d in place of %d bytes", 

Reply via email to