1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! Fuzz / test-only entry point that drives the Linux cmsg walker on an
//! arbitrary byte slice.
//!
//! Gated on `#[cfg(any(fuzzing, test))]` so the module does not exist in
//! normal builds — the public API surface of `varta-watch` is unchanged.
//! `cargo fuzz` sets `--cfg fuzzing` automatically.
//!
//! The fuzz target wraps the input bytes in a Linux `Msghdr` whose
//! `msg_control` / `msg_controllen` describe the slice, then calls
//! `find_credential::<LinuxCmsg>`. The contract: never panics, never
//! returns `Some(..)` for a buffer that doesn't actually contain a
//! well-formed `SCM_CREDENTIALS` cmsg.
use find_credential;
// Access via the `pub(super) use linux::*` re-export in `super::platform`
// rather than `super::platform::linux::*` directly — the inner module is
// private; the re-export is what siblings see.
use ;
/// Drive the unified Linux cmsg walker on `data`. Returns the
/// `(pid, uid)` extracted from the first `SCM_CREDENTIALS` cmsg in the
/// buffer, or `None` if no such cmsg is present / the buffer is malformed.
///
/// Soundness: `find_credential` treats `data.as_ptr()` /
/// `data.len()` as the kernel-supplied `msg_control` / `msg_controllen`.
/// All bounds checks are inside the walker, so any input slice (including
/// empty, oversize, or adversarial bytes) is processed safely.