From c0116d32bea18859f1310ed01d8ac074ac676dda Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 30 Jun 2026 02:45:09 +0400 Subject: test(nres): cover input byte limit enforcement --- crates/fparkan-nres/src/lib.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'crates/fparkan-nres/src/lib.rs') diff --git a/crates/fparkan-nres/src/lib.rs b/crates/fparkan-nres/src/lib.rs index 3a8e264..2511d8c 100644 --- a/crates/fparkan-nres/src/lib.rs +++ b/crates/fparkan-nres/src/lib.rs @@ -1633,6 +1633,34 @@ mod tests { )); } + #[test] + fn decode_rejects_input_bytes_above_limit() { + let bytes = build_archive(&[SyntheticEntry { + type_id: 1, + attr1: 0, + attr2: 0, + attr3: 0, + name: "payload", + payload: b"data", + }]); + let exact_size = u64::try_from(bytes.len()).expect("archive size"); + + assert!(matches!( + decode_with_limits( + arc(bytes), + ReadProfile::Strict, + DecodeLimits { + max_input_bytes: exact_size - 1, + ..DecodeLimits::default() + } + ), + Err(NresError::Binary(DecodeError::LimitExceeded { + count, + limit + })) if count == exact_size && limit == exact_size - 1 + )); + } + #[test] fn decode_rejects_preserved_bytes_above_limit() { let bytes = build_archive_with_nonzero_prefix_gap(&[SyntheticEntry { -- cgit v1.2.3