Skip to content

Commit 4606c49

Browse files
committed
Add test for quoted scan in fallback parser that starts is_escaped.
1 parent 18e8c84 commit 4606c49

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

tests/syntax.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,3 +1119,52 @@ void contiguous_escaped_start(void** state)
11191119
NULL);
11201120
assert_int_equal(result, ZONE_SUCCESS);
11211121
}
1122+
1123+
/*!cmocka */
1124+
void quoted_escaped_start(void** state)
1125+
{
1126+
/* Check that the fallback parser handles a scan of a quoted segment
1127+
* that starts with is_escaped. */
1128+
char* zone =
1129+
"$ORIGIN example.\n"
1130+
"$TTL 3600\n"
1131+
"@ IN SOA ns postmaster.mail 2147483647 3600 900 1814400 900\n"
1132+
" IN NS ns\n"
1133+
"ns IN A 203.0.113.53\n"
1134+
"ns IN AAAA 2001:db8:feed:beef::53\n"
1135+
"\n"
1136+
"0000000 IN A 192.0.2.0\n"
1137+
"0000000 IN TYPE994 \\# 10 30313233343536373839\n"
1138+
"0000001 IN A 192.0.2.1\n"
1139+
"0000001 IN TYPE994 \\# 11 3031323334353637383961\n"
1140+
"0000002 IN A 192.0.2.2\n"
1141+
"0000002 IN TYPE994 \\# 12 303132333435363738396162\n"
1142+
"0000003 IN A 192.0.2.3\n"
1143+
"0000003 IN TYPE994 \\# 13 30313233343536373839616263\n"
1144+
"0000004 IN A 192.0.2.4\n"
1145+
"0000004 IN TYPE994 \\# 14 3031323334353637383961626364\n"
1146+
"0000005 IN A 192.0.2.5\n"
1147+
"0000005 IN TYPE994 \\# 15 303132333435363738396162636465\n"
1148+
"0000006 IN A 192.0.2.6\n"
1149+
"0000006 IN TXT \"aaa\\#\"\n"
1150+
;
1151+
static uint8_t origin[] = { 0 };
1152+
zone_parser_t parser;
1153+
zone_name_buffer_t name;
1154+
zone_rdata_buffer_t rdata;
1155+
zone_buffers_t buffers = { 1, &name, &rdata };
1156+
zone_options_t options;
1157+
int32_t result;
1158+
(void) state;
1159+
1160+
memset(&options, 0, sizeof(options));
1161+
options.accept.callback = contiguous_escaped_start_cb;
1162+
options.origin.octets = origin;
1163+
options.origin.length = sizeof(origin);
1164+
options.default_ttl = 3600;
1165+
options.default_class = ZONE_CLASS_IN;
1166+
1167+
result = zone_parse_string(&parser, &options, &buffers, zone, strlen(zone),
1168+
NULL);
1169+
assert_int_equal(result, ZONE_SUCCESS);
1170+
}

0 commit comments

Comments
 (0)