From 0194a265fe0107e6a9cfbcd5e11ee4d6d592bd3b Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Tue, 9 Sep 2025 12:55:06 -0700 Subject: [PATCH 1/2] check target pointer validity in qctx_save Make sure the target pointer address (getting the allocated instance of qctx) is valid and the pointer is NULL. --- lib/ns/query.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ns/query.c b/lib/ns/query.c index a89d6342e2..0a5a8c1b8c 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -5229,6 +5229,8 @@ qctx_destroy(query_ctx_t *qctx) { */ static void qctx_save(query_ctx_t *src, query_ctx_t **targetp) { + REQUIRE(targetp != NULL && *targetp == NULL); + query_ctx_t *target = isc_mem_get(src->client->manager->mctx, sizeof(query_ctx_t)); From 8204843bc4a5d40ec9fe34f2501a0737f872b056 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Tue, 9 Sep 2025 13:00:23 -0700 Subject: [PATCH 2/2] convert config sh-based hooks tests to python The test cases that call named-checkconf have been moved from tests.sh into the python tests, which are now renamed back to tests_hooks.py. --- bin/tests/system/hooks/tests.sh | 40 ------------------- .../{tests_sh_hooks.py => tests_hooks.py} | 12 +++++- 2 files changed, 10 insertions(+), 42 deletions(-) delete mode 100644 bin/tests/system/hooks/tests.sh rename bin/tests/system/hooks/{tests_sh_hooks.py => tests_hooks.py} (87%) diff --git a/bin/tests/system/hooks/tests.sh b/bin/tests/system/hooks/tests.sh deleted file mode 100644 index d54383b385..0000000000 --- a/bin/tests/system/hooks/tests.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh - -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# SPDX-License-Identifier: MPL-2.0 -# -# 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 https://mozilla.org/MPL/2.0/. -# -# See the COPYRIGHT file distributed with this work for additional -# information regarding copyright ownership. - -set -e - -. ../conf.sh - -status=0 -n=0 - -for conf in conf/good*.conf; do - n=$((n + 1)) - echo_i "checking that $conf is accepted ($n)" - ret=0 - $CHECKCONF "$conf" || ret=1 - if [ $ret != 0 ]; then echo_i "failed"; fi - status=$((status + ret)) -done - -for conf in conf/bad*.conf; do - n=$((n + 1)) - echo_i "checking that $conf is rejected ($n)" - ret=0 - $CHECKCONF "$conf" >/dev/null && ret=1 - if [ $ret != 0 ]; then echo_i "failed"; fi - status=$((status + ret)) -done - -echo_i "exit status: $status" -[ $status -eq 0 ] || exit 1 diff --git a/bin/tests/system/hooks/tests_sh_hooks.py b/bin/tests/system/hooks/tests_hooks.py similarity index 87% rename from bin/tests/system/hooks/tests_sh_hooks.py rename to bin/tests/system/hooks/tests_hooks.py index 93953d1bdf..6c721c31dd 100644 --- a/bin/tests/system/hooks/tests_sh_hooks.py +++ b/bin/tests/system/hooks/tests_hooks.py @@ -9,6 +9,10 @@ # See the COPYRIGHT file distributed with this work for additional # information regarding copyright ownership. +import glob +import os +import subprocess + import dns import pytest import isctest @@ -75,5 +79,9 @@ def test_hooks_zone_rndc_reload(servers): ns2.rndc("reload") -def test_hooks_config(run_tests_sh): - run_tests_sh() +def test_hooks_checkconf(): + for filename in glob.glob("conf/good*.conf"): + isctest.run.cmd([os.environ["CHECKCONF"], filename]) + for filename in glob.glob("conf/bad*.conf"): + with pytest.raises(subprocess.CalledProcessError): + isctest.run.cmd([os.environ["CHECKCONF"], filename])