aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-06-30 01:45:09 +0300
committerValentin Popov <valentin@popov.link>2026-06-30 01:45:09 +0300
commitc0116d32bea18859f1310ed01d8ac074ac676dda (patch)
treec6c9845d5e560845d70d2f984053b15a557ff991 /crates
parent0a7ba55b441f3b36a294b18e96b2887d6fd47b45 (diff)
downloadfparkan-c0116d32bea18859f1310ed01d8ac074ac676dda.tar.xz
fparkan-c0116d32bea18859f1310ed01d8ac074ac676dda.zip
test(nres): cover input byte limit enforcement
Diffstat (limited to 'crates')
-rw-r--r--crates/fparkan-nres/src/lib.rs28
1 files changed, 28 insertions, 0 deletions
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
@@ -1634,6 +1634,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 {
type_id: 1,