2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

Fixed crash when querying for non existing domain in chaos class

Function dns_view_findzonecut in view.c wasn't correctly handling
classes other than IN (chaos, hesiod, etc) whenever the name being
looked up wasn't in cache or in any of the configured zone views' database.

That resulted in a NULL fname being used in resolver.c:4900, which
in turn was triggering abort.
This commit is contained in:
Diego Fronza
2020-01-15 14:39:38 -03:00
parent 754f7588c6
commit 85555f29d7

View File

@@ -1245,8 +1245,9 @@ dns_view_findzonecut(dns_view_t *view, const dns_name_t *name,
ztoptions |= DNS_ZTFIND_NOEXACT; ztoptions |= DNS_ZTFIND_NOEXACT;
result = dns_zt_find(view->zonetable, name, ztoptions, result = dns_zt_find(view->zonetable, name, ztoptions,
NULL, &zone); NULL, &zone);
} else } else {
result = ISC_R_NOTFOUND; result = ISC_R_NOTFOUND;
}
UNLOCK(&view->lock); UNLOCK(&view->lock);
if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH) if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH)
result = dns_zone_getdb(zone, &db); result = dns_zone_getdb(zone, &db);
@@ -1261,12 +1262,15 @@ dns_view_findzonecut(dns_view_t *view, const dns_name_t *name,
* We have a cache; try it. * We have a cache; try it.
*/ */
dns_db_attach(view->cachedb, &db); dns_db_attach(view->cachedb, &db);
} else { } else if (use_hints && view->hints != NULL) {
/* /*
* Maybe we have hints... * Maybe we have hints...
*/ */
try_hints = true; try_hints = true;
goto finish; goto finish;
} else {
result = DNS_R_NXDOMAIN;
goto cleanup;
} }
} else if (result != ISC_R_SUCCESS) { } else if (result != ISC_R_SUCCESS) {
/* /*
@@ -1287,6 +1291,7 @@ dns_view_findzonecut(dns_view_t *view, const dns_name_t *name,
result = ISC_R_SUCCESS; result = ISC_R_SUCCESS;
else if (result != ISC_R_SUCCESS) else if (result != ISC_R_SUCCESS)
goto cleanup; goto cleanup;
if (use_cache && view->cachedb != NULL && db != view->hints) { if (use_cache && view->cachedb != NULL && db != view->hints) {
/* /*
* We found an answer, but the cache may be better. * We found an answer, but the cache may be better.
@@ -1327,13 +1332,16 @@ dns_view_findzonecut(dns_view_t *view, const dns_name_t *name,
* have a zone delegation, so use it. * have a zone delegation, so use it.
*/ */
use_zone = true; use_zone = true;
} else { result = ISC_R_SUCCESS;
} else if (use_hints && view->hints != NULL) {
/* /*
* Maybe we have hints... * Maybe we have hints...
*/ */
try_hints = true; try_hints = true;
result = ISC_R_SUCCESS;
} else {
result = DNS_R_NXDOMAIN;
} }
result = ISC_R_SUCCESS;
} else { } else {
/* /*
* Something bad happened. * Something bad happened.
@@ -1358,7 +1366,7 @@ dns_view_findzonecut(dns_view_t *view, const dns_name_t *name,
if (sigrdataset != NULL && if (sigrdataset != NULL &&
dns_rdataset_isassociated(&zrdataset)) dns_rdataset_isassociated(&zrdataset))
dns_rdataset_clone(&zsigrdataset, sigrdataset); dns_rdataset_clone(&zsigrdataset, sigrdataset);
} else if (try_hints && use_hints && view->hints != NULL) { } else if (try_hints) {
/* /*
* We've found nothing so far, but we have hints. * We've found nothing so far, but we have hints.
*/ */