From 4c08b67a5f01eda472a9dfee4c73dbbac49c0065 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Fri, 1 Dec 2000 09:03:44 +0000 Subject: [PATCH] 586. [bug] multiple views with the same name were fatal. [RT #516] --- CHANGES | 2 ++ lib/dns/config/confparser.y.dirty | 10 ++++++++-- lib/dns/config/confview.c | 31 ++++++++++++++++--------------- lib/dns/include/dns/confview.h | 7 ++++--- 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/CHANGES b/CHANGES index 739f27091f..d88a324bda 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ + 586. [bug] multiple views with the same name were fatal. [RT #516] + 585. [func] dns_db_addrdataset() and and dns_rdataslab_merge() now support 'exact' additions in a similar manner to dns_db_subtractrdataset() and dns_rdataslab_subtract(). diff --git a/lib/dns/config/confparser.y.dirty b/lib/dns/config/confparser.y.dirty index c98c0f85d8..410d52cac4 100644 --- a/lib/dns/config/confparser.y.dirty +++ b/lib/dns/config/confparser.y.dirty @@ -33,7 +33,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: confparser.y.dirty,v 1.32 2000/11/25 02:43:48 marka Exp $ */ +/* $Id: confparser.y.dirty,v 1.33 2000/12/01 09:03:41 marka Exp $ */ #include @@ -3692,7 +3692,13 @@ view_stmt: L_VIEW any_string optional_class L_LBRACE YYABORT; } - dns_c_viewtable_addview(currcfg->views, view); + tmpres = dns_c_viewtable_addview(currcfg->views, view); + if (tmpres == ISC_R_EXISTS) { + dns_c_view_delete(&view); + parser_error(ISC_FALSE, + "view '%s' already exists", $2); + YYABORT; + } dns_c_ctx_setcurrview(currcfg, view); isc_mem_free(memctx, $2); diff --git a/lib/dns/config/confview.c b/lib/dns/config/confview.c index a21600195f..bef450f956 100644 --- a/lib/dns/config/confview.c +++ b/lib/dns/config/confview.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: confview.c,v 1.59 2000/11/28 05:24:51 marka Exp $ */ +/* $Id: confview.c,v 1.60 2000/12/01 09:03:42 marka Exp $ */ #include @@ -275,12 +275,24 @@ dns_c_viewtable_print(FILE *fp, int indent, } -void +isc_result_t dns_c_viewtable_addview(dns_c_viewtable_t *viewtable, dns_c_view_t *view) { + dns_c_view_t *elem; + REQUIRE(DNS_C_VIEWTABLE_VALID(viewtable)); REQUIRE(DNS_C_VIEW_VALID(view)); + elem = ISC_LIST_HEAD(viewtable->views); + while (elem != NULL) { + if (strcmp(view->name, elem->name) == 0) { + return (ISC_R_EXISTS); + } + + elem = ISC_LIST_NEXT(elem, next); + } + ISC_LIST_APPEND(viewtable->views, view, next); + return (ISC_R_SUCCESS); } @@ -299,7 +311,6 @@ isc_result_t dns_c_viewtable_clear(dns_c_viewtable_t *table) { dns_c_view_t *elem; dns_c_view_t *tmpelem; - isc_result_t r; REQUIRE(DNS_C_VIEWTABLE_VALID(table)); @@ -308,15 +319,7 @@ dns_c_viewtable_clear(dns_c_viewtable_t *table) { tmpelem = ISC_LIST_NEXT(elem, next); ISC_LIST_UNLINK(table->views, elem, next); - r = dns_c_view_delete(&elem); - if (r != ISC_R_SUCCESS) { - isc_log_write(dns_lctx, DNS_LOGCATEGORY_CONFIG, - DNS_LOGMODULE_CONFIG, - ISC_LOG_CRITICAL, - "failed to delete view"); - return (r); - } - + dns_c_view_delete(&elem); elem = tmpelem; } @@ -830,7 +833,7 @@ dns_c_view_print(FILE *fp, int indent, dns_c_view_t *view) { -isc_result_t +void dns_c_view_delete(dns_c_view_t **viewptr) { dns_c_view_t *view; @@ -943,8 +946,6 @@ dns_c_view_delete(dns_c_view_t **viewptr) { view->magic = 0; isc_mem_put(view->mem, view, sizeof *view); - - return (ISC_R_SUCCESS); } diff --git a/lib/dns/include/dns/confview.h b/lib/dns/include/dns/confview.h index e217db1634..4f2e54e3b9 100644 --- a/lib/dns/include/dns/confview.h +++ b/lib/dns/include/dns/confview.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: confview.h,v 1.44 2000/11/25 02:43:54 marka Exp $ */ +/* $Id: confview.h,v 1.45 2000/12/01 09:03:44 marka Exp $ */ #ifndef DNS_CONFVIEW_H #define DNS_CONFVIEW_H 1 @@ -192,7 +192,8 @@ isc_result_t dns_c_viewtable_new(isc_mem_t *mem, isc_result_t dns_c_viewtable_delete(dns_c_viewtable_t **viewtable); void dns_c_viewtable_print(FILE *fp, int indent, dns_c_viewtable_t *table); -void dns_c_viewtable_addview(dns_c_viewtable_t *viewtable, dns_c_view_t *view); +isc_result_t dns_c_viewtable_addview(dns_c_viewtable_t *viewtable, + dns_c_view_t *view); void dns_c_viewtable_rmview(dns_c_viewtable_t *viewtable, dns_c_view_t *view); isc_result_t dns_c_viewtable_clear(dns_c_viewtable_t *table); isc_result_t dns_c_viewtable_viewbyname(dns_c_viewtable_t *viewtable, @@ -215,7 +216,7 @@ isc_result_t dns_c_viewtable_checkviews(dns_c_viewtable_t *viewtable); isc_result_t dns_c_view_new(isc_mem_t *mem, const char *name, dns_rdataclass_t viewclass, dns_c_view_t **newview); -isc_result_t dns_c_view_delete(dns_c_view_t **viewptr); +void dns_c_view_delete(dns_c_view_t **viewptr); void dns_c_view_print(FILE *fp, int indent, dns_c_view_t *view); isc_boolean_t dns_c_view_keydefinedp(dns_c_view_t *view, const char *keyname);