]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
ensure dig sets exitcode after local UDP connection failure
authorEvan Hunt <each@isc.org>
Fri, 8 Apr 2022 07:33:24 +0000 (00:33 -0700)
committerEvan Hunt <each@isc.org>
Fri, 15 Apr 2022 17:32:31 +0000 (10:32 -0700)
dig previously set an exit code of 9 when a TCP connection failed
or when a UDP connection timed out, but when the server address is
localhost it's possible for a UDP query to fail with ISC_R_CONNREFUSED.
that code path didn't update the exit code, causing dig to exit with
status 0. we now set the exit code to 9 in this failure case.

bin/dig/dighost.c

index 0b3a66a5c015d4230b3d9e68d070c7a3b7a74976..a4c2865509df3a2dda9e171bac68e1dbacf480ca 100644 (file)
@@ -3120,6 +3120,10 @@ udp_ready(isc_nmhandle_t *handle, isc_result_t eresult, void *arg) {
                dig_lookup_t *l = query->lookup;
 
                debug("udp setup failed: %s", isc_result_totext(eresult));
+
+               if (exitcode < 9) {
+                       exitcode = 9;
+               }
                query_detach(&query);
                cancel_lookup(l);
                lookup_detach(&l);
@@ -3980,6 +3984,8 @@ recv_done(isc_nmhandle_t *handle, isc_result_t eresult, isc_region_t *region,
 
                if (eresult == ISC_R_EOF) {
                        requeue_or_update_exitcode(l);
+               } else if (exitcode < 9) {
+                       exitcode = 9;
                }
 
                goto cancel_lookup;