Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/zone.h
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,10 @@ typedef struct {
a secondary as data may have been transferred over AXFR/IXFR that
would have triggered an error otherwise. */
bool secondary;
/** Programs that process zones that do not need the zone to be in perfect
order (for example programs that count the number of delegations),
may be even more lenient and allow syntax errors. */
bool skip_syntax_errors;
/** Disable $INCLUDE directive. */
/** Useful in setups where untrusted input may be offered. */
bool no_includes;
Expand Down
28 changes: 19 additions & 9 deletions src/bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ static void help(const char *program)
"\n"
"Options:\n"
" -h Display available options.\n"
" -s Continue parsing after a semantic error\n"
" -S Continue parsing after a semantic or syntax error\n"
" -t target Select target (default:%s)\n"
"\n"
"Kernels:\n";
Expand All @@ -183,14 +185,30 @@ int main(int argc, char *argv[])
if (*slash == '/' || *slash == '\\')
program = slash + 1;

for (int option; (option = getopt(argc, argv, "ht:")) != -1;) {
zone_options_t options;
memset(&options, 0, sizeof(options));
options.pretty_ttls = true;
options.origin.octets = root;
options.origin.length = 1;
options.accept.callback = &bench_accept;
options.default_ttl = 3600;
options.default_class = 1;

for (int option; (option = getopt(argc, argv, "ht:sS")) != -1;) {
switch (option) {
case 'h':
help(program);
exit(EXIT_SUCCESS);
case 't':
name = optarg;
break;
case 's':
options.secondary = true;
break;
case 'S':
options.secondary = true;
options.skip_syntax_errors = true;
break;
default:
usage(program);
}
Expand All @@ -213,14 +231,6 @@ int main(int argc, char *argv[])

zone_parser_t parser;
memset(&parser, 0, sizeof(parser));
zone_options_t options;
memset(&options, 0, sizeof(options));
options.pretty_ttls = true;
options.origin.octets = root;
options.origin.length = 1;
options.accept.callback = &bench_accept;
options.default_ttl = 3600;
options.default_class = 1;

zone_name_buffer_t owner;
zone_rdata_buffer_t rdata;
Expand Down
6 changes: 4 additions & 2 deletions src/generic/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,10 @@ static inline int32_t parse(parser_t *parser)

if ((code = parse_owner(parser, &rr, &fields[0], &token)) < 0)
return code;
if ((code = take_contiguous(parser, &rr, &fields[0], &token)) < 0)
return code;
if ((code = take_contiguous(parser, &rr, &fields[0], &token)) < 0) {
if(code == ZONE_SYNTAX_ERROR && !parser->options.skip_syntax_errors)
return code;
}
} else if (unlikely(!parser->owner->length)) {
SYNTAX_ERROR(parser, "No last stated owner");
}
Expand Down
3 changes: 2 additions & 1 deletion src/generic/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ static never_inline int32_t raise_error(
{
va_list arguments;
uint32_t category = ZONE_ERROR;
if (code == ZONE_SEMANTIC_ERROR && parser->options.secondary)
if ((code == ZONE_SEMANTIC_ERROR && parser->options.secondary)
|| (code == ZONE_SYNTAX_ERROR && parser->options.skip_syntax_errors))
category = ZONE_WARNING;
va_start(arguments, format);
zone_vlog(parser, category, format, arguments);
Expand Down
12 changes: 6 additions & 6 deletions tests/semantics.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ void ds_digest_lengths(void **state)
{ 4, 47, ZONE_SEMANTIC_ERROR },
{ 4, 49, ZONE_SEMANTIC_ERROR },
// 5: GOST R 34.10-2012
{ 5, 48, ZONE_SUCCESS },
{ 5, 47, ZONE_SEMANTIC_ERROR },
{ 5, 49, ZONE_SEMANTIC_ERROR },
{ 5, 32, ZONE_SUCCESS },
{ 5, 31, ZONE_SEMANTIC_ERROR },
{ 5, 33, ZONE_SEMANTIC_ERROR },
// 6: SM3
{ 6, 48, ZONE_SUCCESS },
{ 6, 47, ZONE_SEMANTIC_ERROR },
{ 6, 49, ZONE_SEMANTIC_ERROR }
{ 6, 32, ZONE_SUCCESS },
{ 6, 31, ZONE_SEMANTIC_ERROR },
{ 6, 33, ZONE_SEMANTIC_ERROR }
};

(void)state;
Expand Down