From fe8e9c194784d0cac0ab807880dcac52ad73b0ab Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sun, 3 Jan 2021 15:56:44 +0530 Subject: [PATCH] DomainTree: returning null in ConvertKeyToLabel() when domain length is less than 1. --- DnsServerCore/Dns/Zones/DomainTree.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/DnsServerCore/Dns/Zones/DomainTree.cs b/DnsServerCore/Dns/Zones/DomainTree.cs index a1b48a45..4437a5d0 100644 --- a/DnsServerCore/Dns/Zones/DomainTree.cs +++ b/DnsServerCore/Dns/Zones/DomainTree.cs @@ -1,6 +1,6 @@ /* Technitium DNS Server -Copyright (C) 2020 Shreyas Zare (shreyas@technitium.com) +Copyright (C) 2021 Shreyas Zare (shreyas@technitium.com) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -158,7 +158,11 @@ namespace DnsServerCore.Dns.Zones protected static string ConvertKeyToLabel(byte[] key, int startIndex) { - byte[] domain = new byte[key.Length - startIndex]; + int length = key.Length - startIndex; + if (length < 1) + return null; + + byte[] domain = new byte[length]; int i; int k;