]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Do not allow defining "http" clauses named "default"
authorArtem Boldariev <artem@boldariev.com>
Thu, 30 Sep 2021 09:40:03 +0000 (12:40 +0300)
committerArtem Boldariev <artem@boldariev.com>
Mon, 4 Oct 2021 14:28:30 +0000 (17:28 +0300)
This name is reserved for being used in 'listen-on' statements only.

bin/tests/system/checkconf/bad-doh-default.conf [new file with mode: 0644]
lib/bind9/check.c

diff --git a/bin/tests/system/checkconf/bad-doh-default.conf b/bin/tests/system/checkconf/bad-doh-default.conf
new file mode 100644 (file)
index 0000000..9e4fa7b
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * 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.
+ */
+
+# 'default' is a built-in configuration intended to be used in
+# 'listen-on' statements
+http default {
+       endpoints { "/dns-query"; };
+       listener-clients 100;
+       streams-per-connection 100;
+};
index 84b899953a37b2ccfd11902dcb8c47c9c62bb3d6..ac1ab2f4a916949cf4c71279e6e6ea79c89dce59 100644 (file)
@@ -2040,27 +2040,35 @@ bind9_check_httpserver(const cfg_obj_t *http, isc_log_t *logctx,
        const cfg_listelt_t *elt = NULL;
        isc_symvalue_t symvalue;
 
-       /* Check for duplicates */
-       symvalue.as_cpointer = http;
-       result = isc_symtab_define(symtab, name, 1, symvalue,
-                                  isc_symexists_reject);
-       if (result == ISC_R_EXISTS) {
-               const char *file = NULL;
-               unsigned int line;
+       if (strcasecmp(name, "default") == 0) {
+               cfg_obj_log(http, logctx, ISC_LOG_ERROR,
+                           "'http' name cannot be '%s' (which is a "
+                           "built-in configuration)",
+                           name);
+               result = ISC_R_FAILURE;
+       } else {
+               /* Check for duplicates */
+               symvalue.as_cpointer = http;
+               result = isc_symtab_define(symtab, name, 1, symvalue,
+                                          isc_symexists_reject);
+               if (result == ISC_R_EXISTS) {
+                       const char *file = NULL;
+                       unsigned int line;
+
+                       tresult = isc_symtab_lookup(symtab, name, 1, &symvalue);
+                       RUNTIME_CHECK(tresult == ISC_R_SUCCESS);
 
-               tresult = isc_symtab_lookup(symtab, name, 1, &symvalue);
-               RUNTIME_CHECK(tresult == ISC_R_SUCCESS);
+                       line = cfg_obj_line(symvalue.as_cpointer);
+                       file = cfg_obj_file(symvalue.as_cpointer);
+                       if (file == NULL) {
+                               file = "<unknown file>";
+                       }
 
-               line = cfg_obj_line(symvalue.as_cpointer);
-               file = cfg_obj_file(symvalue.as_cpointer);
-               if (file == NULL) {
-                       file = "<unknown file>";
+                       cfg_obj_log(http, logctx, ISC_LOG_ERROR,
+                                   "http '%s' is duplicated: "
+                                   "also defined at %s:%u",
+                                   name, file, line);
                }
-
-               cfg_obj_log(http, logctx, ISC_LOG_ERROR,
-                           "http '%s' is duplicated: "
-                           "also defined at %s:%u",
-                           name, file, line);
        }
 
        /* Check endpoints are valid */