pub fn validate_bounded_len<R>(
source: &R,
label: &str,
len: usize,
min_element_size: usize,
) -> Result<(), DeserializationError>where
R: ByteReader,Expand description
Validates that a serialized length fits both the reader budget and remaining input.
This guards against malicious length prefixes that would otherwise cause a compact payload to be amplified into a large allocation.
§Errors
Returns DeserializationError::InvalidValue if:
lenexceeds the number of elements the reader’s remaining budget allows.len * min_element_sizeoverflows.- The source does not hold
len * min_element_sizemore bytes.