From: florian Date: Tue, 18 Apr 2023 09:57:08 +0000 (+0000) Subject: Improve asr error handling. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=43bd63ce9688e1aa63c59d9420c1792c4dca6206;p=openbsd Improve asr error handling. When an upstream nameserver is not available asr is not synthesizing a SERVFAIL rcode (duh), but sets ar_errno. When we need SERVFAIL further down,we need to set the rcode ourselves. While here, don't complain about a too short packet when asr already told us that resolving did not work out in check_dns64_done. OK semarie --- diff --git a/sbin/unwind/resolver.c b/sbin/unwind/resolver.c index 71614237506..0682e9e4d70 100644 --- a/sbin/unwind/resolver.c +++ b/sbin/unwind/resolver.c @@ -1,4 +1,4 @@ -/* $OpenBSD: resolver.c,v 1.158 2023/02/08 08:01:25 tb Exp $ */ +/* $OpenBSD: resolver.c,v 1.159 2023/04/18 09:57:08 florian Exp $ */ /* @@ -1623,8 +1623,9 @@ void asr_resolve_done(struct asr_result *ar, void *arg) { struct resolver_cb_data *cb_data = arg; - cb_data->cb(cb_data->res, cb_data->data, ar->ar_rcode, ar->ar_data, - ar->ar_datalen, 0, NULL); + cb_data->cb(cb_data->res, cb_data->data, ar->ar_errno == 0 ? + ar->ar_rcode : LDNS_RCODE_SERVFAIL, ar->ar_data, ar->ar_datalen, 0, + NULL); free(ar->ar_data); resolver_unref(cb_data->res); free(cb_data); @@ -2289,6 +2290,9 @@ check_dns64_done(struct asr_result *ar, void *arg) int preflen, count = 0; void *asr_ctx = arg; + if (ar->ar_errno != 0) + goto fail; + memset(&qinfo, 0, sizeof(qinfo)); alloc_init(&alloc, NULL, 0); @@ -2390,6 +2394,7 @@ check_dns64_done(struct asr_result *ar, void *arg) alloc_clear(&alloc); regional_destroy(region); sldns_buffer_free(buf); + fail: free(ar->ar_data); asr_resolver_free(asr_ctx); }