From d368d43ec74ca9b25a37d4b1722f7137bbce8887 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Tue, 12 Feb 2002 13:17:23 +0000 Subject: [PATCH] Allocate and free key used to check for duplicate zones. --- lib/bind9/check.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/bind9/check.c b/lib/bind9/check.c index f90d6af5c7..6265e442f2 100644 --- a/lib/bind9/check.c +++ b/lib/bind9/check.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: check.c,v 1.20 2002/02/11 00:46:26 marka Exp $ */ +/* $Id: check.c,v 1.21 2002/02/12 13:17:23 marka Exp $ */ #include @@ -24,10 +24,11 @@ #include #include +#include +#include #include #include #include -#include #include #include @@ -116,7 +117,7 @@ typedef struct { static isc_result_t check_zoneconf(cfg_obj_t *zconfig, isc_symtab_t *symtab, - dns_rdataclass_t defclass, isc_log_t *logctx) + dns_rdataclass_t defclass, isc_log_t *logctx, isc_mem_t *mctx) { const char *zname; const char *typestr; @@ -244,10 +245,15 @@ check_zoneconf(cfg_obj_t *zconfig, isc_symtab_t *symtab, result = ISC_R_FAILURE; } else { char namebuf[DNS_NAME_FORMATSIZE]; + char *key; + dns_name_format(dns_fixedname_name(&fixedname), namebuf, sizeof(namebuf)); + key = isc_mem_strdup(mctx, namebuf); + if (key == NULL) + return (ISC_R_NOMEMORY); symvalue.as_pointer = NULL; - tresult = isc_symtab_define(symtab, namebuf, + tresult = isc_symtab_define(symtab, key, ztype == HINTZONE ? 1 : 2, symvalue, isc_symexists_reject); if (tresult == ISC_R_EXISTS) { @@ -411,6 +417,13 @@ check_keylist(cfg_obj_t *keys, isc_symtab_t *symtab, isc_log_t *logctx) { } return (result); } + +static void +freekey(char *key, unsigned int type, isc_symvalue_t value, void *userarg) { + UNUSED(type); + UNUSED(value); + isc_mem_free(userarg, key); +} static isc_result_t check_viewconf(cfg_obj_t *config, cfg_obj_t *vconfig, dns_rdataclass_t vclass, @@ -427,7 +440,8 @@ check_viewconf(cfg_obj_t *config, cfg_obj_t *vconfig, dns_rdataclass_t vclass, * Check that all zone statements are syntactically correct and * there are no duplicate zones. */ - tresult = isc_symtab_create(mctx, 100, NULL, NULL, ISC_TRUE, &symtab); + tresult = isc_symtab_create(mctx, 100, freekey, mctx, + ISC_TRUE, &symtab); if (tresult != ISC_R_SUCCESS) return (ISC_R_NOMEMORY); @@ -443,7 +457,7 @@ check_viewconf(cfg_obj_t *config, cfg_obj_t *vconfig, dns_rdataclass_t vclass, isc_result_t tresult; cfg_obj_t *zone = cfg_listelt_value(element); - tresult = check_zoneconf(zone, symtab, vclass, logctx); + tresult = check_zoneconf(zone, symtab, vclass, logctx, mctx); if (tresult != ISC_R_SUCCESS) result = ISC_R_FAILURE; }