chore: audit cleanup, CI, cargo-deny, encode fuzz target (0.3.4)
CI / Test (1.93) (push) Canceled after 0s
CI / Test (stable) (push) Canceled after 0s
CI / Test (1.83, legacy-msrv) (push) Canceled after 0s
CI / Clippy (push) Canceled after 0s
CI / Format (push) Canceled after 0s
CI / Doc (push) Canceled after 0s
CI / Cargo Deny (push) Canceled after 0s
CI / Test (1.93) (push) Canceled after 0s
CI / Test (stable) (push) Canceled after 0s
CI / Test (1.83, legacy-msrv) (push) Canceled after 0s
CI / Clippy (push) Canceled after 0s
CI / Format (push) Canceled after 0s
CI / Doc (push) Canceled after 0s
CI / Cargo Deny (push) Canceled after 0s
Simplify encoder exit branch (−41 B code size), add GitHub Actions CI with MSRV matrix, cargo-deny with permissive-only license policy, encode-only fuzz target, and feature coverage across test gates. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
11 files changed
+226
-38
No files matched your search
@@ -30,3 +30,9 @@ name = "fuzz_small_dest"
|
||||
path = "fuzz_targets/fuzz_small_dest.rs"
|
||||
test = false
|
||||
doc = false
|
||||
|
||||
[[bin]]
|
||||
name = "fuzz_encode"
|
||||
path = "fuzz_targets/fuzz_encode.rs"
|
||||
test = false
|
||||
doc = false
|
||||
@@ -0,0 +1,33 @@
|
||||
//! Fuzz target: encode arbitrary input into buffers of varying sizes.
|
||||
//! Exercises encode error paths (buffer too small) and validates output properties.
|
||||
#![no_main]
|
||||
use libfuzzer_sys::fuzz_target;
|
||||
|
||||
fuzz_target!(|data: &[u8]| {
|
||||
if data.len() > 1024 {
|
||||
return;
|
||||
}
|
||||
|
||||
let max = ucobs::max_encoded_len(data.len());
|
||||
|
||||
// Encode into a correctly-sized buffer — must always succeed.
|
||||
let mut buf = vec![0u8; max];
|
||||
let n = ucobs::encode(data, &mut buf)
|
||||
.expect("encode failed with max_encoded_len buffer");
|
||||
let encoded = &buf[..n];
|
||||
|
||||
// Output must never contain 0x00.
|
||||
assert!(!encoded.contains(&0x00), "encoded output contains 0x00");
|
||||
|
||||
// Output length must be bounded by max_encoded_len.
|
||||
assert!(n <= max, "encoded length exceeds max_encoded_len");
|
||||
|
||||
// Output must be at least 1 byte (even empty input encodes to [0x01]).
|
||||
assert!(n >= 1, "encoded length is zero");
|
||||
|
||||
// Encode into every possible undersized buffer — must return None, never panic.
|
||||
for size in 0..n {
|
||||
let mut small = vec![0u8; size];
|
||||
assert_eq!(ucobs::encode(data, &mut small), None);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user