Skip to main content

MAX_RECURSION_DEPTH

Constant MAX_RECURSION_DEPTH 

pub const MAX_RECURSION_DEPTH: usize = 50;
Expand description

Maximum recursion depth for parsing marshaling descriptors.

This constant limits the depth of nested type parsing to prevent stack overflow from maliciously crafted or corrupted marshalling descriptors. The limit is set conservatively to handle legitimate complex types while preventing denial-of-service attacks.

§Security Considerations

Without recursion limits, an attacker could create deeply nested type descriptors that cause stack overflow during parsing. This limit provides defense against such attacks while still supporting reasonable nesting scenarios.

§Practical Limits

In practice, .NET marshalling descriptors rarely exceed 10-15 levels of nesting. The limit of 50 provides substantial headroom for complex legitimate scenarios.