From 4eee6460ff38dd268576d998b2eeed807d3d6f10 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Fri, 8 Apr 2022 00:33:24 -0700 Subject: [PATCH 1/2] ensure dig sets exitcode after local UDP connection failure 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 0b3a66a5c0..a4c2865509 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -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; From d646aca2821dad32c729514389f33bfe93176e96 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Fri, 8 Apr 2022 00:39:46 -0700 Subject: [PATCH 2/2] CHANGES for [GL #3235] --- CHANGES | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES b/CHANGES index 8802affb59..ddf2570485 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +5862. [bug] dig returned a 0 exit status on UDP connection failure. + [GL #3235] + 5861. [func] Implement support for catalog zones change of ownership (coo) mechanism described in the DNS catalog zones draft version 5 document. [GL #3223]