From 38608fc7f235f04d8fe790101be71a13c5d97d75 Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sat, 14 Dec 2019 18:04:18 +0530 Subject: [PATCH] Zone: SetRecords() added check to prevent CNAME record from being set to zone root. --- DnsServerCore/Dns/Zone.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/DnsServerCore/Dns/Zone.cs b/DnsServerCore/Dns/Zone.cs index c57e88c7..837a0535 100644 --- a/DnsServerCore/Dns/Zone.cs +++ b/DnsServerCore/Dns/Zone.cs @@ -204,7 +204,7 @@ namespace DnsServerCore.Dns } foreach (Zone subDomain in subDomainsToDelete) - currentZone._zones.TryRemove(subDomain._zoneLabel, out Zone deletedValue); + currentZone._zones.TryRemove(subDomain._zoneLabel, out _); return (currentZone._zones.Count == 0); } @@ -384,6 +384,9 @@ namespace DnsServerCore.Dns } } + if (_authoritativeZone && (type == DnsResourceRecordType.CNAME) && _entries.ContainsKey(DnsResourceRecordType.SOA)) + throw new DnsServerException("Cannot add CNAME record to zone root."); + _entries.AddOrUpdate(type, records, delegate (DnsResourceRecordType key, DnsResourceRecord[] existingValues) { return records;