From: W.C.A. Wijngaards Date: Tue, 21 May 2024 09:54:18 +0000 (+0200) Subject: - Fix to print a parse error when config is read with no name for X-Git-Tag: release-1.21.0rc1~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86ee8ccd121d6ad2db41e065b7d5e63605a324b2;p=thirdparty%2Funbound.git - Fix to print a parse error when config is read with no name for a forward-zone, stub-zone or view. --- diff --git a/doc/Changelog b/doc/Changelog index 39aa7f25b..ac5c03a13 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,6 +1,8 @@ 21 May 2024: Wouter - Merge #1073: fix null pointer dereference issue in function ub_ctx_set_fwd. + - Fix to print a parse error when config is read with no name for + a forward-zone, stub-zone or view. 17 May 2024: Yorgos - Merge #1069: Fix unbound-control stdin commands for multi-process diff --git a/util/configparser.y b/util/configparser.y index 0feeb61b1..2e82da5d7 100644 --- a/util/configparser.y +++ b/util/configparser.y @@ -358,7 +358,13 @@ stubstart: VAR_STUB_ZONE } ; contents_stub: contents_stub content_stub - | ; + | + { + /* stub end */ + if(cfg_parser->cfg->stubs && + !cfg_parser->cfg->stubs->name) + yyerror("stub-zone without name"); + }; content_stub: stub_name | stub_host | stub_addr | stub_prime | stub_first | stub_no_cache | stub_ssl_upstream | stub_tcp_upstream ; @@ -377,7 +383,13 @@ forwardstart: VAR_FORWARD_ZONE } ; contents_forward: contents_forward content_forward - | ; + | + { + /* forward end */ + if(cfg_parser->cfg->forwards && + !cfg_parser->cfg->forwards->name) + yyerror("forward-zone without name"); + }; content_forward: forward_name | forward_host | forward_addr | forward_first | forward_no_cache | forward_ssl_upstream | forward_tcp_upstream ; @@ -389,8 +401,6 @@ viewstart: VAR_VIEW s = (struct config_view*)calloc(1, sizeof(struct config_view)); if(s) { s->next = cfg_parser->cfg->views; - if(s->next && !s->next->name) - yyerror("view without name"); cfg_parser->cfg->views = s; } else { yyerror("out of memory"); @@ -398,7 +408,13 @@ viewstart: VAR_VIEW } ; contents_view: contents_view content_view - | ; + | + { + /* view end */ + if(cfg_parser->cfg->views && + !cfg_parser->cfg->views->name) + yyerror("view without name"); + }; content_view: view_name | view_local_zone | view_local_data | view_first | view_response_ip | view_response_ip_data | view_local_data_ptr ;