mirror of
https://github.com/NLnetLabs/unbound.git
synced 2026-02-03 20:29:28 -05:00
- Max include depth is unlimited.
git-svn-id: file:///svn/unbound/trunk@2909 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
eaf464e591
commit
f7bf35b23a
5 changed files with 219 additions and 192 deletions
|
|
@ -874,8 +874,6 @@ char *strptime(const char *s, const char *format, struct tm *tm);
|
|||
# endif
|
||||
#endif /* CHECKED_INET6 */
|
||||
|
||||
/* maximum nesting of included files */
|
||||
#define MAXINCLUDES 10
|
||||
#ifndef HAVE_GETADDRINFO
|
||||
struct sockaddr_storage;
|
||||
#include "compat/fake-rfc2553.h"
|
||||
|
|
|
|||
|
|
@ -1214,8 +1214,6 @@ char *strptime(const char *s, const char *format, struct tm *tm);
|
|||
# endif
|
||||
#endif /* CHECKED_INET6 */
|
||||
|
||||
/* maximum nesting of included files */
|
||||
#define MAXINCLUDES 10
|
||||
#ifndef HAVE_GETADDRINFO
|
||||
struct sockaddr_storage;
|
||||
#include "compat/fake-rfc2553.h"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
10 Jun 2013: Wouter
|
||||
- Fix#501: forward-first does not recurse, when forward name is ".".
|
||||
- iana portlist update.
|
||||
- Max include depth is unlimited.
|
||||
|
||||
27 May 2013: Wouter
|
||||
- Update acx_pthreads.m4 to ax_pthreads.4 (2013-03-29), and apply
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -39,43 +39,54 @@ void ub_c_error(const char *message);
|
|||
struct inc_state {
|
||||
char* filename;
|
||||
int line;
|
||||
YY_BUFFER_STATE buffer;
|
||||
struct inc_state* next;
|
||||
};
|
||||
static struct inc_state parse_stack[MAXINCLUDES];
|
||||
static YY_BUFFER_STATE include_stack[MAXINCLUDES];
|
||||
static int config_include_stack_ptr = 0;
|
||||
static struct inc_state* config_include_stack = NULL;
|
||||
static int inc_prev = 0;
|
||||
static int num_args = 0;
|
||||
|
||||
|
||||
static void config_start_include(const char* filename)
|
||||
{
|
||||
FILE *input;
|
||||
struct inc_state* s;
|
||||
char* nm;
|
||||
if(strlen(filename) == 0) {
|
||||
ub_c_error_msg("empty include file name");
|
||||
return;
|
||||
}
|
||||
if(config_include_stack_ptr >= MAXINCLUDES) {
|
||||
ub_c_error_msg("includes nested too deeply, skipped (>%d)", MAXINCLUDES);
|
||||
s = (struct inc_state*)malloc(sizeof(*s));
|
||||
if(!s) {
|
||||
ub_c_error_msg("include %s: malloc failure", filename);
|
||||
return;
|
||||
}
|
||||
if(cfg_parser->chroot && strncmp(filename, cfg_parser->chroot,
|
||||
strlen(cfg_parser->chroot)) == 0) {
|
||||
filename += strlen(cfg_parser->chroot);
|
||||
}
|
||||
nm = strdup(filename);
|
||||
if(!nm) {
|
||||
ub_c_error_msg("include %s: malloc failure", filename);
|
||||
free(s);
|
||||
return;
|
||||
}
|
||||
input = fopen(filename, "r");
|
||||
if(!input) {
|
||||
ub_c_error_msg("cannot open include file '%s': %s",
|
||||
filename, strerror(errno));
|
||||
free(s);
|
||||
free(nm);
|
||||
return;
|
||||
}
|
||||
LEXOUT(("switch_to_include_file(%s) ", filename));
|
||||
parse_stack[config_include_stack_ptr].filename = cfg_parser->filename;
|
||||
parse_stack[config_include_stack_ptr].line = cfg_parser->line;
|
||||
include_stack[config_include_stack_ptr] = YY_CURRENT_BUFFER;
|
||||
cfg_parser->filename = strdup(filename);
|
||||
LEXOUT(("switch_to_include_file(%s)\n", filename));
|
||||
s->filename = cfg_parser->filename;
|
||||
s->line = cfg_parser->line;
|
||||
s->buffer = YY_CURRENT_BUFFER;
|
||||
s->next = config_include_stack;
|
||||
config_include_stack = s;
|
||||
cfg_parser->filename = nm;
|
||||
cfg_parser->line = 1;
|
||||
yy_switch_to_buffer(yy_create_buffer(input, YY_BUF_SIZE));
|
||||
++config_include_stack_ptr;
|
||||
}
|
||||
|
||||
static void config_start_include_glob(const char* filename)
|
||||
|
|
@ -126,12 +137,15 @@ static void config_start_include_glob(const char* filename)
|
|||
|
||||
static void config_end_include(void)
|
||||
{
|
||||
--config_include_stack_ptr;
|
||||
struct inc_state* s = config_include_stack;
|
||||
if(!s) return;
|
||||
free(cfg_parser->filename);
|
||||
cfg_parser->filename = parse_stack[config_include_stack_ptr].filename;
|
||||
cfg_parser->line = parse_stack[config_include_stack_ptr].line;
|
||||
cfg_parser->filename = s->filename;
|
||||
cfg_parser->line = s->line;
|
||||
yy_delete_buffer(YY_CURRENT_BUFFER);
|
||||
yy_switch_to_buffer(include_stack[config_include_stack_ptr]);
|
||||
yy_switch_to_buffer(s->buffer);
|
||||
config_include_stack = s->next;
|
||||
free(s);
|
||||
}
|
||||
|
||||
#ifndef yy_set_bol /* compat definition, for flex 2.4.6 */
|
||||
|
|
@ -367,8 +381,9 @@ max-udp-size{COLON} { YDVAR(1, VAR_MAX_UDP_SIZE) }
|
|||
BEGIN(inc_prev);
|
||||
}
|
||||
<INITIAL,val><<EOF>> {
|
||||
LEXOUT(("LEXEOF "));
|
||||
yy_set_bol(1); /* Set beginning of line, so "^" rules match. */
|
||||
if (config_include_stack_ptr == 0) {
|
||||
if (!config_include_stack) {
|
||||
yyterminate();
|
||||
} else {
|
||||
fclose(yyin);
|
||||
|
|
|
|||
Loading…
Reference in a new issue