From 532ff5a32e1e21ddc91a3e00a0ba8f0fabeda7d7 Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sun, 4 Dec 2022 13:04:57 +0530 Subject: [PATCH] AuthManager: added code to enforce limit of max 255 users and groups. --- DnsServerCore/Auth/AuthManager.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/DnsServerCore/Auth/AuthManager.cs b/DnsServerCore/Auth/AuthManager.cs index a39c088d..b36f56cc 100644 --- a/DnsServerCore/Auth/AuthManager.cs +++ b/DnsServerCore/Auth/AuthManager.cs @@ -446,6 +446,9 @@ namespace DnsServerCore.Auth public User CreateUser(string displayName, string username, string password, int iterations = User.DEFAULT_ITERATIONS) { + if (_users.Count >= byte.MaxValue) + throw new DnsWebServiceException("Cannot create more than 255 users."); + username = username.ToLower(); User user = new User(displayName, username, password, iterations); @@ -534,6 +537,9 @@ namespace DnsServerCore.Auth public Group CreateGroup(string name, string description) { + if (_groups.Count >= byte.MaxValue) + throw new DnsWebServiceException("Cannot create more than 255 groups."); + Group group = new Group(name, description); if (_groups.TryAdd(name.ToLower(), group))