Skip to content

Commit

Permalink
reproduce error stack overflow from . as MX target
Browse files Browse the repository at this point in the history
stop additional lookup on Root name
  • Loading branch information
bluejekyll committed Jan 5, 2020
1 parent 414c8bf commit 8b9eab0
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions crates/server/src/store/file/authority.rs
Expand Up @@ -92,6 +92,7 @@ impl FileAuthority {
origin,
records.len()
);
debug!("zone: {:#?}", records);

FileAuthority::new(origin, records, zone_type, allow_axfr)
}
Expand Down
3 changes: 2 additions & 1 deletion crates/server/src/store/in_memory/authority.rs
Expand Up @@ -227,7 +227,8 @@ impl InMemoryAuthority {
and_rrsigs: bool,
supported_algorithms: SupportedAlgorithms,
) -> Option<Arc<RecordSet>> {
let wildcard = if name.is_wildcard() {
// if this is a wildcard or a root, both should break continued lookups
let wildcard = if name.is_wildcard() || name.is_root() {
return None;
} else {
name.clone().into_wildcard()
Expand Down
27 changes: 27 additions & 0 deletions crates/server/tests/authority_battery/basic.rs
Expand Up @@ -146,6 +146,29 @@ pub fn test_mx<A: Authority<Lookup = AuthLookup>>(authority: A) {
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), *aaaa);
}

pub fn test_mx_to_null<A: Authority<Lookup = AuthLookup>>(authority: A) {
let query = Query::query(
Name::from_str("no-service.example.com.").unwrap(),
RecordType::MX,
);

let mut lookup =
block_on(authority.search(&query.into(), false, SupportedAlgorithms::new())).unwrap();

// In this case there should be no additional records
assert!(lookup.take_additionals().is_none());

let mx = lookup
.into_iter()
.next()
.expect("MX record not found in authority")
.rdata()
.as_mx()
.expect("Not an MX record");

assert_eq!(Name::from_str(".").unwrap(), *mx.exchange());
}

pub fn test_cname<A: Authority<Lookup = AuthLookup>>(authority: A) {
let query = Query::query(
Name::from_str("alias.example.com.").unwrap(),
Expand Down Expand Up @@ -565,6 +588,9 @@ macro_rules! define_basic_test {
$(
#[test]
fn $f () {
// Useful for getting debug logs
// env_logger::init();

let authority = crate::$new("../../tests/test-data/named_test_configs/example.com.zone", module_path!(), stringify!($f));
crate::authority_battery::basic::$f(authority);
}
Expand All @@ -583,6 +609,7 @@ macro_rules! basic_battery {
test_ns,
test_ns_lookup,
test_mx,
test_mx_to_null,
test_cname,
test_cname_alias,
test_cname_chain,
Expand Down
2 changes: 2 additions & 0 deletions tests/test-data/named_test_configs/example.com.zone
Expand Up @@ -27,3 +27,5 @@ aname-chain ANAME alias
server SRV 1 1 443 alias

*.wildcard CNAME www

no-service 86400 IN MX 0 .

0 comments on commit 8b9eab0

Please sign in to comment.