{"record":{"id":"8d4eee12eee62dc7","repo":"peass-ng/PEASS-ng","slug":"array-has-insufficient-capacity-to-support-copy","errorCode":null,"errorMessage":"Array has insufficient capacity to support copy.","messagePattern":"Array has insufficient capacity to support copy\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/TaskScheduler/NamedValueCollection.cs","lineNumber":602,"sourceCode":"                }\n            }\n            return false;\n        }\n\n        bool IDictionary<string, string>.ContainsKey(string key) => Names.Contains(key);\n\n        void ICollection<KeyValuePair<string, string>>.Add(KeyValuePair<string, string> item)\n        {\n            Add(item.Key, item.Value);\n        }\n\n        bool ICollection<KeyValuePair<string, string>>.Contains(KeyValuePair<string, string> item) =>\n            ((ICollection<NameValuePair>)this).Contains(new NameValuePair(item.Key, item.Value));\n\n        void ICollection<KeyValuePair<string, string>>.CopyTo(KeyValuePair<string, string>[] array, int arrayIndex)\n        {\n            if (array.Length < Count + arrayIndex)\n                throw new ArgumentOutOfRangeException(nameof(array), @\"Array has insufficient capacity to support copy.\");\n            foreach (var item in ((IEnumerable<KeyValuePair<string, string>>)this))\n                array[arrayIndex++] = item;\n        }\n\n        bool ICollection<KeyValuePair<string, string>>.Remove(KeyValuePair<string, string> item) =>\n            ((ICollection<NameValuePair>)this).Remove(new NameValuePair(item.Key, item.Value));\n\n        IEnumerator<KeyValuePair<string, string>> IEnumerable<KeyValuePair<string, string>>.GetEnumerator()\n        {\n            foreach (var nvp in this)\n                yield return new KeyValuePair<string, string>(nvp.Name, nvp.Value);\n        }\n    }\n}\n","sourceCodeStart":584,"sourceCodeEnd":617,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/TaskScheduler/NamedValueCollection.cs#L584-L617","documentation":"ICollection<KeyValuePair<string, string>>.CopyTo throws ArgumentException when the KeyValuePair destination array is too small to receive all name/value pairs (insufficient capacity given the array length and start index). The destination array sizing, not the collection, is at fault.","triggerScenarios":"Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/NamedValueCollection.cs:602 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Size the destination array to at least Count + arrayIndex.","Copy via LINQ (Select + ToArray) instead of CopyTo to avoid manual sizing.","Copy in batches if the destination array is fixed-size."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}