{"record":{"id":"2eda17a3994fb03e","repo":"peass-ng/PEASS-ng","slug":"str","errorCode":null,"errorMessage":"str","messagePattern":"str","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/asn1/DerBmpString.cs","lineNumber":61,"sourceCode":"        {\n            Asn1Object o = obj.GetObject();\n\n            if (isExplicit || o is DerBmpString)\n            {\n                return GetInstance(o);\n            }\n\n            return new DerBmpString(Asn1OctetString.GetInstance(o).GetOctets());\n        }\n\n        /**\n         * basic constructor - byte encoded string.\n         */\n        [Obsolete(\"Will become internal\")]\n        public DerBmpString(byte[] str)\n        {\n            if (str == null)\n                throw new ArgumentNullException(\"str\");\n\n            int byteLen = str.Length;\n            if (0 != (byteLen & 1))\n                throw new ArgumentException(\"malformed BMPString encoding encountered\", \"str\");\n\n            int charLen = byteLen / 2;\n            char[] cs = new char[charLen];\n\n            for (int i = 0; i != charLen; i++)\n            {\n                cs[i] = (char)((str[2 * i] << 8) | (str[2 * i + 1] & 0xff));\n            }\n\n            this.str = new string(cs);\n        }\n\n        internal DerBmpString(char[] str)\n        {","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/asn1/DerBmpString.cs#L43-L79","documentation":"This obsolete byte-array constructor of DerBmpString throws ArgumentNullException when the caller passes a null byte array; it fires at the very first guard of the constructor before any encoding length checks, meaning the code constructed a BMP string from a null buffer.","triggerScenarios":"Calling new DerBmpString((byte[])null) — e.g. passing the result of a failed encode or a null field extracted from a structure.","commonSituations":"Bridge code converting strings to bytes where the string was null; decoding pipelines that propagate null instead of empty arrays.","solutions":["Pass a non-null byte[]; use Array.Empty<byte>() if there is genuinely no content.","Construct from a string instead: new DerBmpString(\"text\") handles encoding for you.","Fix the upstream producer that returned null and handle its failure case."],"exampleFix":"// before\nvar bmp = new DerBmpString(GetEncodedName()); // may return null\n// after\nbyte[] enc = GetEncodedName() ?? Array.Empty<byte>();\nvar bmp = new DerBmpString(enc);","handlingStrategy":"validation","validationCode":"if (str == null) throw new InvalidOperationException(\"BMPString byte content missing\");","typeGuard":"static bool HasBmpBytes(byte[] b) => b != null;","tryCatchPattern":null,"preventionTips":["Prefer the public string constructor over raw byte[]","Null-coalesce byte producers before constructing ASN.1 objects","Handle decode failures at the source instead of propagating null"],"tags":["csharp","asn1","null-argument","bouncycastle"],"backgroundTag":"null-argument","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}