diff --git a/bin/tests/system/checkconf/tests.sh b/bin/tests/system/checkconf/tests.sh index 46a2773be2..cc5db0439e 100644 --- a/bin/tests/system/checkconf/tests.sh +++ b/bin/tests/system/checkconf/tests.sh @@ -56,6 +56,15 @@ EOF $CHECKCONF badzero.conf > /dev/null 2>&1 [ $? -eq 1 ] || { echo "I: view $field failed" ; ret=1; } cat > badzero.conf << EOF +options { + $field 0; +}; +view dummy { +}; +EOF + $CHECKCONF badzero.conf > /dev/null 2>&1 + [ $? -eq 1 ] || { echo "I: options + view $field failed" ; ret=1; } + cat > badzero.conf << EOF zone dummy { type slave; masters { 0.0.0.0; }; diff --git a/lib/bind9/check.c b/lib/bind9/check.c index c6fa4fca4b..b43bb7076a 100644 --- a/lib/bind9/check.c +++ b/lib/bind9/check.c @@ -1787,9 +1787,15 @@ check_viewconf(const cfg_obj_t *config, const cfg_obj_t *voptions, isc_result_t result = ISC_R_SUCCESS; isc_result_t tresult = ISC_R_SUCCESS; cfg_aclconfctx_t actx; + const cfg_obj_t *options = NULL; const cfg_obj_t *obj; isc_boolean_t enablednssec, enablevalidation; + /* + * Get global options block. + */ + (void)cfg_map_get(config, "options", &options); + /* * Check that all zone statements are syntactically correct and * there are no duplicate zones. @@ -1825,28 +1831,27 @@ check_viewconf(const cfg_obj_t *config, const cfg_obj_t *voptions, * Check that forwarding is reasonable. */ if (voptions == NULL) { - const cfg_obj_t *options = NULL; - (void)cfg_map_get(config, "options", &options); - if (options != NULL) { + if (options != NULL) if (check_forward(options, NULL, logctx) != ISC_R_SUCCESS) result = ISC_R_FAILURE; - if (check_nonzero(options, logctx) != ISC_R_SUCCESS) - result = ISC_R_FAILURE; - } } else { if (check_forward(voptions, NULL, logctx) != ISC_R_SUCCESS) result = ISC_R_FAILURE; - if (check_nonzero(voptions, logctx) != ISC_R_SUCCESS) - result = ISC_R_FAILURE; } + /* + * Check non-zero options at the global and view levels. + */ + if (options != NULL && check_nonzero(options, logctx) != ISC_R_SUCCESS) + result = ISC_R_FAILURE; + if (voptions != NULL &&check_nonzero(voptions, logctx) != ISC_R_SUCCESS) + result = ISC_R_FAILURE; + /* * Check that dual-stack-servers is reasonable. */ if (voptions == NULL) { - const cfg_obj_t *options = NULL; - (void)cfg_map_get(config, "options", &options); if (options != NULL) if (check_dual_stack(options, logctx) != ISC_R_SUCCESS) result = ISC_R_FAILURE;