peass-ng/PEASS-ng · error · ArgumentNullException
str
Error message
str
What it means
The DerGeneralString(string) constructor requires a non-null string; a null argument cannot be encoded as a GeneralString, so ArgumentNullException is raised immediately. This is standard fail-fast argument validation.
Source
Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/asn1/DerGeneralString.cs:48
if (isExplicit || o is DerGeneralString)
{
return GetInstance(o);
}
return new DerGeneralString(((Asn1OctetString)o).GetOctets());
}
public DerGeneralString(
byte[] str)
: this(Strings.FromAsciiByteArray(str))
{
}
public DerGeneralString(
string str)
{
if (str == null)
throw new ArgumentNullException("str");
this.str = str;
}
public override string GetString()
{
return str;
}
public byte[] GetOctets()
{
return Strings.ToAsciiByteArray(str);
}
internal override void Encode(
DerOutputStream derOut)
{
derOut.WriteEncoded(Asn1Tags.GeneralString, GetOctets());View on GitHub (pinned to 53fb989abc)
Solutions
- Pass a non-null string, substituting string.Empty or a default when the value may be absent
- Null-check or coalesce before constructing: new DerGeneralString(str ?? "")
- If absence must be represented, omit the ASN.1 element entirely rather than encoding null
Example fix
// before var gs = new DerGeneralString(maybeNull); // after var gs = new DerGeneralString(maybeNull ?? string.Empty);
Defensive patterns
Strategy: validation
Validate before calling
var gs = str != null ? new DerGeneralString(str) : null;
Try / catch
try { var gs = new DerGeneralString(str); }
catch (ArgumentNullException) { /* use default or omit element */ } Prevention
- Coalesce nulls before constructing ASN.1 string objects
- Enable C# nullable reference types
When it happens
Trigger: Calling new DerGeneralString(null) directly, or passing a null string obtained from configuration, database, or parsed input into the constructor.
Common situations: Null config values or missing data fields fed into ASN.1 building code; API responses with absent string fields; refactoring that introduced a nullable string where a value was assumed.
Related errors
- data
- str
- ENUMERATED has zero length
- input vector too large
- No tagged object found in vector. Structure doesn't seem to
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/84c0e5303f0c2c9b.
Report an issue: GitHub.