Skip to main content

MAX_RANGE_EXPR_CHUNKS

Constant MAX_RANGE_EXPR_CHUNKS 

Source
pub const MAX_RANGE_EXPR_CHUNKS: usize = 10_000;
Expand description

Maximum number of comma-separated sub-ranges in a single range expression.

Each sub-range becomes one IntRange entry in the parsed RangeExpr. Real-world range expressions (frame ranges, task chunks) contain at most a few dozen sub-ranges; 10,000 is two orders of magnitude above any plausible legitimate use. Rejecting larger inputs at parse time prevents an attacker from forcing a multi-megabyte Vec<IntRange> allocation through a parameter value before any downstream resource-bounding (e.g. the evaluator’s memory limit) applies.

This cap targets the source-text and heap dimensions of a RangeExpr. It does not cap the logical element count of a single chunk — RangeExpr stores chunks symbolically (start, end, step), so a single-chunk range "1-100000000000" allocates only one IntRange regardless of its logical length. Downstream materialization (e.g. list(range_expr)) is already bounded by the evaluator’s per-element operation charge and memory limit.

See specs/expr/range-expr.md (Defensive caps) for rationale.