peass-ng/PEASS-ng · error · ArgumentNullException
str
Error message
str
What it means
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.
Source
Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/util/encoders/HexEncoder.cs:219
outStream.Write(buf, 0, bufOff);
bufOff = 0;
}
length++;
}
if (bufOff > 0)
{
outStream.Write(buf, 0, bufOff);
}
return length;
}
internal byte[] DecodeStrict(string str, int off, int len)
{
if (null == str)
throw new ArgumentNullException("str");
if (off < 0 || len < 0 || off > (str.Length - len))
throw new IndexOutOfRangeException("invalid offset and/or length specified");
if (0 != (len & 1))
throw new ArgumentException("a hexadecimal encoding must have an even number of characters", "len");
int resultLen = len >> 1;
byte[] result = new byte[resultLen];
int strPos = off;
for (int i = 0; i < resultLen; ++i)
{
byte b1 = decodingTable[str[strPos++]];
byte b2 = decodingTable[str[strPos++]];
if ((b1 | b2) >= 0x80)
throw new IOException("invalid characters encountered in Hex data");
result[i] = (byte)((b1 << 4) | b2);View on GitHub (pinned to 53fb989abc)
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.
Example fix
// before
var bytes = Hex.Decode(str); // str is null
// after
if (str == null) throw new InvalidOperationException("hex input was not provided");
var bytes = Hex.Decode(str); Defensive patterns
Strategy: type-guard
Validate before calling
if (string.IsNullOrEmpty(str)) throw new ArgumentException("hex input required", nameof(str)); Type guard
static bool IsDecodableHex(string s) => !string.IsNullOrEmpty(s) && s.Length % 2 == 0 && s.All(Uri.IsHexDigit);
Try / catch
try { decodeStrict(str, 0, str.Length); } catch (ArgumentNullException) { return Array.Empty<byte>(); } Prevention
- 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
When it happens
Trigger: 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.
Common situations: Variables that were never assigned from parsed input; deserialization producing null strings; API callers not honoring the non-null contract.
Related errors
- invalid offset and/or length specified
- a hexadecimal encoding must have an even number of character
- invalid characters encountered in Hex data
- drivePath
- Resources.InvalidDriveLetterArgument
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/1a8c605b9545aa01.
Report an issue: GitHub.