From 821d89c5f68496f90d58d9d4afd14295f812fc8a Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sun, 4 Dec 2022 13:04:21 +0530 Subject: [PATCH] Permission: fixed serialization issue caused when more than 255 zones are added. --- DnsServerCore/Auth/Permission.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/DnsServerCore/Auth/Permission.cs b/DnsServerCore/Auth/Permission.cs index 05ac906b..83524c83 100644 --- a/DnsServerCore/Auth/Permission.cs +++ b/DnsServerCore/Auth/Permission.cs @@ -81,9 +81,11 @@ namespace DnsServerCore.Auth public Permission(BinaryReader bR, AuthManager authManager) { - switch (bR.ReadByte()) + byte version = bR.ReadByte(); + switch (version) { case 1: + case 2: _section = (PermissionSection)bR.ReadByte(); { @@ -115,7 +117,13 @@ namespace DnsServerCore.Auth } { - int count = bR.ReadByte(); + int count; + + if (version >= 2) + count = bR.ReadInt32(); + else + count = bR.ReadByte(); + _subItemPermissions = new ConcurrentDictionary(1, count); for (int i = 0; i < count; i++) @@ -276,7 +284,7 @@ namespace DnsServerCore.Auth public void WriteTo(BinaryWriter bW) { - bW.Write((byte)1); + bW.Write((byte)2); bW.Write((byte)_section); { @@ -300,7 +308,7 @@ namespace DnsServerCore.Auth } { - bW.Write(Convert.ToByte(_subItemPermissions.Count)); + bW.Write(_subItemPermissions.Count); foreach (KeyValuePair subItemPermission in _subItemPermissions) {