Skip to content

Commit d0f3766

Browse files
committed
Require last stated owner for RRs
1 parent 8758796 commit d0f3766

File tree

5 files changed

+153
-133
lines changed

5 files changed

+153
-133
lines changed

src/generic/format.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,14 +374,16 @@ static inline int32_t parse(parser_t *parser)
374374
else if (token.length == 8 && memcmp(token.data, "$INCLUDE", 8) == 0)
375375
code = parse_dollar_include(parser, &token);
376376
else
377-
SYNTAX_ERROR(parser, "Invalid control entry");
377+
SYNTAX_ERROR(parser, "Unknown control entry");
378378
continue;
379379
}
380380

381381
if ((code = parse_owner(parser, &rr, &fields[0], &token)) < 0)
382382
return code;
383383
if ((code = take_contiguous(parser, &rr, &fields[0], &token)) < 0)
384384
return code;
385+
} else if (unlikely(!parser->owner->length)) {
386+
SYNTAX_ERROR(parser, "No last stated owner");
385387
}
386388

387389
code = parse_rr(parser, &token);

tests/base32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void base32_syntax(void **state)
6767

6868
for (size_t i=0, n=sizeof(tests)/sizeof(tests[0]); i < n; i++) {
6969
char rr[256];
70-
const char rrfmt[] = " NSEC3 1 1 12 aabbccdd ( %s A NS )";
70+
const char rrfmt[] = "foo. NSEC3 1 1 12 aabbccdd ( %s A NS )";
7171
zone_parser_t parser = { 0 };
7272
zone_name_buffer_t name;
7373
zone_rdata_buffer_t rdata;

tests/ip4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void ipv4_syntax(void **state)
8989
zone_options_t options = { 0 };
9090
int32_t result;
9191

92-
(void)snprintf(rr, sizeof(rr), " A %s", tests[i].address);
92+
(void)snprintf(rr, sizeof(rr), "foo. A %s", tests[i].address);
9393

9494
options.accept.callback = add_rr;
9595
options.origin.octets = origin;

tests/syntax.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,24 @@ static int32_t parse_as_include(const char *text, size_t *count)
564564
return code;
565565
}
566566

567+
/*!cmocka */
568+
void who_dis(void **state)
569+
{
570+
(void)state;
571+
572+
int32_t code;
573+
size_t count = 0;
574+
static const char *dat = PAD(" TXT \"dat\"");
575+
static const char *dis_n_dat = PAD("dis. TXT \"dis\"\n"
576+
" TXT \"dat\"");
577+
578+
code = parse(dat, &count);
579+
assert_int_equal(code, ZONE_SYNTAX_ERROR);
580+
code = parse(dis_n_dat, &count);
581+
assert_int_equal(code, ZONE_SUCCESS);
582+
assert_true(count == 2);
583+
}
584+
567585
/*!cmocka */
568586
void quote_no_unquote(void **state)
569587
{

0 commit comments

Comments
 (0)