{"record":{"id":"5d48f214b97be4ef","repo":"TechnitiumSoftware/DnsServer","slug":"qpm-prefix-limits-for-ipv6-cannot-have-more-than-2","errorCode":null,"errorMessage":"QPM Prefix Limits for IPv6 cannot have more than 255 entries.","messagePattern":"QPM Prefix Limits for IPv6 cannot have more than 255 entries\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/DnsServer.cs","lineNumber":7442,"sourceCode":"                    _qpmPrefixLimitsIPv4 = value;\n                }\n\n                ResetQpsLimitTimer();\n            }\n        }\n\n        public IReadOnlyDictionary<int, (int, int)> QpmPrefixLimitsIPv6\n        {\n            get { return _qpmPrefixLimitsIPv6; }\n            set\n            {\n                if (value is null)\n                {\n                    _qpmPrefixLimitsIPv6 = new Dictionary<int, (int, int)>();\n                }\n                else if (value.Count > byte.MaxValue)\n                {\n                    throw new ArgumentOutOfRangeException(nameof(QpmPrefixLimitsIPv6), \"QPM Prefix Limits for IPv6 cannot have more than 255 entries.\");\n                }\n                else\n                {\n                    foreach (KeyValuePair<int, (int, int)> qpmPrefixLimit in value)\n                    {\n                        if ((qpmPrefixLimit.Key < 0) || (qpmPrefixLimit.Key > 128))\n                            throw new ArgumentOutOfRangeException(nameof(QpmPrefixLimitsIPv6), \"QPM limit IPv6 prefix valid range is between 0 and 128.\");\n\n                        if ((qpmPrefixLimit.Value.Item1 < 0) || (qpmPrefixLimit.Value.Item2 < 0))\n                            throw new ArgumentOutOfRangeException(nameof(QpmPrefixLimitsIPv6), \"QPM limit value cannot be less than 0.\");\n                    }\n\n                    _qpmPrefixLimitsIPv6 = value;\n                }\n\n                ResetQpsLimitTimer();\n            }\n        }","sourceCodeStart":7424,"sourceCodeEnd":7460,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/DnsServer.cs#L7424-L7460","documentation":"Thrown by the QpmPrefixLimitsIPv6 property setter when the dictionary has more than 255 entries. QPM IPv6 prefix limits are serialized with a byte count, capping entries at 255. A null value resets to an empty dictionary.","triggerScenarios":"Assigning server.QpmPrefixLimitsIPv6 a dictionary with Count > 255.","commonSituations":"Generating one entry per possible IPv6 prefix length (0-128 is only 129, so this needs duplicates or an overly-generated set); loading a malformed external config.","solutions":["Reduce to 255 or fewer entries; there are only 129 valid IPv6 prefix lengths (0-128).","Check for duplicate or redundant keys.","Set to null to clear."],"exampleFix":"// before\nserver.QpmPrefixLimitsIPv6 = oversizedMap; // >255\n\n// after\nserver.QpmPrefixLimitsIPv6 =\n    oversizedMap.Take(128).ToDictionary(k => k.Key, v => v.Value);","handlingStrategy":"validation","validationCode":"if (qpmV6.Count > 255)\n    qpmV6 = qpmV6.Take(255).ToDictionary(k => k.Key, v => v.Value);\nserver.QpmPrefixLimitsIPv6 = qpmV6;","typeGuard":"static bool IsValidQpmDict(Dictionary<int,(int,int)> d) =>\n    d is null || d.Count <= 255;","tryCatchPattern":"try { server.QpmPrefixLimitsIPv6 = qpmV6; }\ncatch (ArgumentOutOfRangeException) { qpmV6 = qpmV6.Take(255).ToDictionary(k=>k.Key,v=>v.Value); server.QpmPrefixLimitsIPv6 = qpmV6; }","preventionTips":["Only 129 valid IPv6 prefix lengths (0-128) exist — dedupe before building.","Cap dictionary size during generation."],"tags":["dns","qpm","rate-limiting","ipv6","configuration"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}