]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
check that name field is not a valid type
authorMark Andrews <marka@isc.org>
Thu, 6 Sep 2018 09:36:17 +0000 (19:36 +1000)
committerMark Andrews <marka@isc.org>
Mon, 10 Sep 2018 07:16:10 +0000 (17:16 +1000)
(cherry picked from commit 5fb75a3d75946fbdb3cd1ed3229b81724a1d40f3)

bin/tests/system/checkconf/tests.sh
lib/bind9/check.c

index 89b6fdaef32dbe69f58e315a81d459039e82d905..7e4bb8f1b0daa2df1d293c166f4961df65d22753 100644 (file)
@@ -54,10 +54,14 @@ do
        pat="identity and name fields are not the same"
        grep "$pat" checkconf.out > /dev/null || ret=1
        ;;
-    bad-update-policy*.conf)
+    bad-update-policy[4589].conf)
        pat="name field not set to placeholder value"
        grep "$pat" checkconf.out > /dev/null || ret=1
        ;;
+    bad-update-policy[67].conf)
+       pat="missing name field type '.*' found"
+       grep "$pat" checkconf.out > /dev/null || ret=1
+       ;;
     esac
     if [ $ret != 0 ]; then echo_i "failed"; fi
     status=`expr $status + $ret`
index 67cc45fdcc780e0e0d15038160c5cbb4ba4c4ff2..3b078e0225e109c7d092b695b4c74dcae04dd726 100644 (file)
@@ -1729,6 +1729,8 @@ check_update_policy(const cfg_obj_t *policy, isc_log_t *logctx) {
        dns_fixedname_t fixed_id, fixed_name;
        dns_name_t *id, *name;
        const char *str;
+       isc_textregion_t r;
+       dns_rdatatype_t type;
 
        /* Check for "update-policy local;" */
        if (cfg_obj_isstring(policy) &&
@@ -1766,12 +1768,16 @@ check_update_policy(const cfg_obj_t *policy, isc_log_t *logctx) {
                }
 
                /*
-                * There is no name field for subzone.
+                * There is no name field for subzone and dname is void
                 */
-               if (tresult == ISC_R_SUCCESS &&
-                   mtype != dns_ssumatchtype_subdomain)
+               if (mtype == dns_ssumatchtype_subdomain &&
+                   cfg_obj_isvoid(dname))
                {
+                       str = ".";      /* Use "." as a replacement. */
+               } else {
                        str = cfg_obj_asstring(dname);
+               }
+               if (tresult == ISC_R_SUCCESS) {
                        tresult = dns_name_fromstring(name, str, 0, NULL);
                        if (tresult != ISC_R_SUCCESS) {
                                cfg_obj_log(dname, logctx, ISC_LOG_ERROR,
@@ -1819,12 +1825,24 @@ check_update_policy(const cfg_obj_t *policy, isc_log_t *logctx) {
                        }
                        break;
                case dns_ssumatchtype_name:
-               case dns_ssumatchtype_subdomain:
+               case dns_ssumatchtype_subdomain: /* also zonesub */
                case dns_ssumatchtype_subdomainms:
                case dns_ssumatchtype_subdomainkrb5:
                case dns_ssumatchtype_wildcard:
                case dns_ssumatchtype_external:
                case dns_ssumatchtype_local:
+                       if (tresult == ISC_R_SUCCESS) {
+                               DE_CONST(str, r.base);
+                               r.length = strlen(str);
+                               tresult = dns_rdatatype_fromtext(&type, &r);
+                       }
+                       if (tresult == ISC_R_SUCCESS) {
+                               cfg_obj_log(identity, logctx, ISC_LOG_ERROR,
+                                           "missing name field type '%s' "
+                                           "found", str);
+                               result = ISC_R_FAILURE;
+                               break;
+                       }
                        break;
                default:
                        INSIST(0);
@@ -1835,8 +1853,6 @@ check_update_policy(const cfg_obj_t *policy, isc_log_t *logctx) {
                     element2 = cfg_list_next(element2))
                {
                        const cfg_obj_t *typeobj;
-                       isc_textregion_t r;
-                       dns_rdatatype_t type;
 
                        typeobj = cfg_listelt_value(element2);
                        DE_CONST(cfg_obj_asstring(typeobj), r.base);