MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / check_decoded_size

Function check_decoded_size

nodedb-array/src/codec/limits.rs:45–54  ·  view source on GitHub ↗

Reject a length value that exceeds `cap`. Used everywhere a `usize` length is decoded from segment bytes.

(value: usize, cap: usize, what: &str)

Source from the content-addressed store, hash-verified

43/// Reject a length value that exceeds `cap`. Used everywhere a `usize`
44/// length is decoded from segment bytes.
45pub fn check_decoded_size(value: usize, cap: usize, what: &str) -> ArrayResult<()> {
46 if value > cap {
47 return Err(ArrayError::SegmentCorruption {
48 detail: format!(
49 "decoded {what} = {value} exceeds hard cap {cap} (segment likely corrupt)"
50 ),
51 });
52 }
53 Ok(())
54}

Callers 4

decode_rleFunction · 0.85
decode_attr_colFunction · 0.85
decode_structuralFunction · 0.85
decode_coord_axisFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected