]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Check that primary tls names are syntactically valid
authorMark Andrews <marka@isc.org>
Wed, 4 Aug 2021 07:33:00 +0000 (17:33 +1000)
committerMark Andrews <marka@isc.org>
Wed, 25 Aug 2021 05:21:14 +0000 (15:21 +1000)
bin/tests/system/checkconf/bad-primaries-tls.conf [new file with mode: 0644]
lib/bind9/check.c

diff --git a/bin/tests/system/checkconf/bad-primaries-tls.conf b/bin/tests/system/checkconf/bad-primaries-tls.conf
new file mode 100644 (file)
index 0000000..abb54ba
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+zone example {
+        type secondary;
+        primaries { 1.2.3.4 tls a..b; };
+};
index fb88e0b229a9045607745e1ccd7c425c4a29b55f..570a2e8ed39623cf3be52ddcc897147f1bfc209a 100644 (file)
@@ -2114,10 +2114,12 @@ resume:
                const char *listname;
                const cfg_obj_t *addr;
                const cfg_obj_t *key;
+               const cfg_obj_t *tls;
 
                addr = cfg_tuple_get(cfg_listelt_value(element),
                                     "remoteselement");
                key = cfg_tuple_get(cfg_listelt_value(element), "key");
+               tls = cfg_tuple_get(cfg_listelt_value(element), "tls");
 
                if (cfg_obj_issockaddr(addr)) {
                        count++;
@@ -2135,6 +2137,20 @@ resume:
                                        }
                                }
                        }
+                       if (cfg_obj_isstring(tls)) {
+                               const char *str = cfg_obj_asstring(tls);
+                               dns_fixedname_t fname;
+                               dns_name_t *nm = dns_fixedname_initname(&fname);
+                               tresult = dns_name_fromstring(nm, str, 0, NULL);
+                               if (tresult != ISC_R_SUCCESS) {
+                                       cfg_obj_log(tls, logctx, ISC_LOG_ERROR,
+                                                   "'%s' is not a valid name",
+                                                   str);
+                                       if (result == ISC_R_SUCCESS) {
+                                               result = tresult;
+                                       }
+                               }
+                       }
                        continue;
                }
                if (!cfg_obj_isvoid(key)) {
@@ -2145,6 +2161,14 @@ resume:
                                result = ISC_R_FAILURE;
                        }
                }
+               if (!cfg_obj_isvoid(tls)) {
+                       cfg_obj_log(key, logctx, ISC_LOG_ERROR,
+                                   "unexpected token '%s'",
+                                   cfg_obj_asstring(tls));
+                       if (result == ISC_R_SUCCESS) {
+                               result = ISC_R_FAILURE;
+                       }
+               }
                listname = cfg_obj_asstring(addr);
                symvalue.as_cpointer = addr;
                tresult = isc_symtab_define(symtab, listname, 1, symvalue,