{"record":{"id":"1a8c605b9545aa01","repo":"peass-ng/PEASS-ng","slug":"str-1a8c60","errorCode":null,"errorMessage":"str","messagePattern":"str","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/util/encoders/HexEncoder.cs","lineNumber":219,"sourceCode":"                    outStream.Write(buf, 0, bufOff);\n                    bufOff = 0;\n                }\n\n                length++;\n            }\n\n            if (bufOff > 0)\n            {\n                outStream.Write(buf, 0, bufOff);\n            }\n\n            return length;\n        }\n\n        internal byte[] DecodeStrict(string str, int off, int len)\n        {\n            if (null == str)\n                throw new ArgumentNullException(\"str\");\n            if (off < 0 || len < 0 || off > (str.Length - len))\n                throw new IndexOutOfRangeException(\"invalid offset and/or length specified\");\n            if (0 != (len & 1))\n                throw new ArgumentException(\"a hexadecimal encoding must have an even number of characters\", \"len\");\n\n            int resultLen = len >> 1;\n            byte[] result = new byte[resultLen];\n\n            int strPos = off;\n            for (int i = 0; i < resultLen; ++i)\n            {\n                byte b1 = decodingTable[str[strPos++]];\n                byte b2 = decodingTable[str[strPos++]];\n\n                if ((b1 | b2) >= 0x80)\n                    throw new IOException(\"invalid characters encountered in Hex data\");\n\n                result[i] = (byte)((b1 << 4) | b2);","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/util/encoders/HexEncoder.cs#L201-L237","documentation":"HexEncoder.DecodeStrict is the internal strict hex decoder. It validates arguments before decoding: a null string throws ArgumentNullException with param name 'str'. The library throws this to fail fast on a null input instead of throwing NullReferenceException deep inside the decode loop.","triggerScenarios":"Calling an internal/reflective path that passes a null string to DecodeStrict(string str, int off, int len) — e.g. Hex.Decode with a null argument on strict-mode overloads.","commonSituations":"Variables that were never assigned from parsed input; deserialization producing null strings; API callers not honoring the non-null contract.","solutions":["Ensure the string is non-null before calling the decode API (coalesce to empty string or reject).","Add an explicit null check with a meaningful error at your boundary.","Catch ArgumentNullException and report which input was missing."],"exampleFix":"// before\nvar bytes = Hex.Decode(str); // str is null\n// after\nif (str == null) throw new InvalidOperationException(\"hex input was not provided\");\nvar bytes = Hex.Decode(str);","handlingStrategy":"type-guard","validationCode":"if (string.IsNullOrEmpty(str)) throw new ArgumentException(\"hex input required\", nameof(str));","typeGuard":"static bool IsDecodableHex(string s) => !string.IsNullOrEmpty(s) && s.Length % 2 == 0 && s.All(Uri.IsHexDigit);","tryCatchPattern":"try { decodeStrict(str, 0, str.Length); } catch (ArgumentNullException) { return Array.Empty<byte>(); }","preventionTips":["Initialize hex string variables at declaration","Fail early at input boundaries with explicit null checks","Use non-null assertions/nullable annotations to catch nulls at compile time"],"tags":["csharp","null","argument","hex"],"backgroundTag":"null-argument","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}