2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00

rndc: sync ISC_R_CANCELED handling in callbacks

rndc_recvdone() is not treating the ISC_R_CANCELED result code as a
request to stop data processing, which may cause a crash when trying to
dereference ccmsg->buffer.  Fix by ensuring ISC_R_CANCELED results in an
early exit from rndc_recvdone().

Make sure the logic for handling ISC_R_CANCELED in rndc_recvnonce()
matches the one present in rndc_recvdone() to ensure consistent behavior
between these two sibling functions.
This commit is contained in:
Evan Hunt
2022-01-13 11:18:27 -08:00
committed by Michał Kępień
parent 710f62bf39
commit 289c1d33ee

View File

@@ -316,7 +316,7 @@ static void
rndc_recvdone(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
isccc_ccmsg_t *ccmsg = (isccc_ccmsg_t *)arg;
isccc_sexpr_t *response = NULL;
isccc_sexpr_t *data;
isccc_sexpr_t *data = NULL;
isccc_region_t source;
char *errormsg = NULL;
char *textmsg = NULL;
@@ -339,7 +339,7 @@ rndc_recvdone(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
"* the clocks are not synchronized,\n"
"* the key signing algorithm is incorrect,\n"
"* or the key is invalid.");
} else if (result != ISC_R_SUCCESS && result != ISC_R_CANCELED) {
} else if (result != ISC_R_SUCCESS) {
fatal("recv failed: %s", isc_result_totext(result));
}
@@ -414,7 +414,7 @@ rndc_recvnonce(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
REQUIRE(ccmsg != NULL);
if (shuttingdown && result == ISC_R_EOF) {
if (shuttingdown && (result == ISC_R_EOF || result == ISC_R_CANCELED)) {
atomic_fetch_sub_release(&recvs, 1);
if (handle != NULL) {
REQUIRE(recvnonce_handle == handle);