- Fix to print a parse error when config is read with no name for

a forward-zone, stub-zone or view.
This commit is contained in:
W.C.A. Wijngaards 2024-05-21 11:54:18 +02:00
parent 8d6a1ba811
commit 86ee8ccd12
2 changed files with 23 additions and 5 deletions

View file

@ -1,6 +1,8 @@
21 May 2024: Wouter 21 May 2024: Wouter
- Merge #1073: fix null pointer dereference issue in function - Merge #1073: fix null pointer dereference issue in function
ub_ctx_set_fwd. 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 17 May 2024: Yorgos
- Merge #1069: Fix unbound-control stdin commands for multi-process - Merge #1069: Fix unbound-control stdin commands for multi-process

View file

@ -358,7 +358,13 @@ stubstart: VAR_STUB_ZONE
} }
; ;
contents_stub: contents_stub content_stub 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 | content_stub: stub_name | stub_host | stub_addr | stub_prime | stub_first |
stub_no_cache | stub_ssl_upstream | stub_tcp_upstream stub_no_cache | stub_ssl_upstream | stub_tcp_upstream
; ;
@ -377,7 +383,13 @@ forwardstart: VAR_FORWARD_ZONE
} }
; ;
contents_forward: contents_forward content_forward 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 | content_forward: forward_name | forward_host | forward_addr | forward_first |
forward_no_cache | forward_ssl_upstream | forward_tcp_upstream 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)); s = (struct config_view*)calloc(1, sizeof(struct config_view));
if(s) { if(s) {
s->next = cfg_parser->cfg->views; s->next = cfg_parser->cfg->views;
if(s->next && !s->next->name)
yyerror("view without name");
cfg_parser->cfg->views = s; cfg_parser->cfg->views = s;
} else { } else {
yyerror("out of memory"); yyerror("out of memory");
@ -398,7 +408,13 @@ viewstart: VAR_VIEW
} }
; ;
contents_view: contents_view content_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 | content_view: view_name | view_local_zone | view_local_data | view_first |
view_response_ip | view_response_ip_data | view_local_data_ptr view_response_ip | view_response_ip_data | view_local_data_ptr
; ;