From: Mark Andrews Date: Wed, 4 Aug 2021 07:23:07 +0000 (+1000) Subject: Check that primary key names are syntactically valid X-Git-Tag: v9.17.18~22^2~2 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=4fa9d8389a1739cebcda00a94ea36bb67199f0b1;p=thirdparty%2Fbind9.git Check that primary key names are syntactically valid --- diff --git a/bin/tests/system/checkconf/bad-primaries-key.conf b/bin/tests/system/checkconf/bad-primaries-key.conf new file mode 100644 index 00000000000..c58f79a8398 --- /dev/null +++ b/bin/tests/system/checkconf/bad-primaries-key.conf @@ -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 key a..b; }; +}; diff --git a/lib/bind9/check.c b/lib/bind9/check.c index d247962fc7f..fb88e0b229a 100644 --- a/lib/bind9/check.c +++ b/lib/bind9/check.c @@ -2121,6 +2121,20 @@ resume: if (cfg_obj_issockaddr(addr)) { count++; + if (cfg_obj_isstring(key)) { + const char *str = cfg_obj_asstring(key); + 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(key, logctx, ISC_LOG_ERROR, + "'%s' is not a valid name", + str); + if (result == ISC_R_SUCCESS) { + result = tresult; + } + } + } continue; } if (!cfg_obj_isvoid(key)) {