Subject
libc 0.2.186 is the canonical Rust crate for raw FFI bindings to platform C standard library interfaces and OS syscall ABIs. It exposes extern "C" function declarations, #[repr(C)] struct and union definitions, integer constants, and a small set of inline helpers that implement C preprocessor macros (BPF_CLASS, CMSG_SPACE, FD_SET, SO_EE_OFFENDER, etc.) as Rust functions. The crate covers over 80 target triples spanning Linux, macOS, Windows, FreeBSD, and numerous embedded/RTOS platforms, organized under src/unix/, src/windows/, and per-OS subdirectories. It is a direct dependency of the Rust standard library via the rustc-dep-of-std feature.
Methodology
The published crate contents were compared against the upstream Git repository at the commit recorded in .cargo_vcs_info.json using diff -rq. The build.rs was read in full. src/lib.rs and src/macros.rs were read in full. Representative platform modules (src/unix/linux_like/linux/mod.rs, src/unix/mod.rs, src/unix/linux_like/mod.rs) were sampled for unsafe usage patterns and helper function implementations. Source surveys for network, filesystem, process, environment, crypto, and concurrency usage were conducted with grep. The test files (src/macros.rs #[test] blocks, tests/const_fn.rs) were read in full.
Scope. Due to the size of this crate (133K LOC, 228 unsafe occurrences across per-OS FFI declarations and inline helpers), the following claims were not evaluated and are left unasserted; they must not be read as either satisfied or violated: unsafe-safe, unsafe-documented, unsafe-minimal, unsafe-tested. This audit verifies supply-chain integrity (VCS byte-equivalence), the capability surface (uses-*), build/install-time execution, and dependency enumeration.
Results
The diff against VCS shows only a single difference: Cargo.toml (cargo normalization). All source files are byte-for-byte identical to the VCS checkout, justifying the supply-chain integrity check.
No binary artifacts are present in the published crate, justifying has-binaries. No install-time hooks exist, justifying has-install-exec.
The build.rs invokes $RUSTC --version and, when targeting FreeBSD or Emscripten, the host tools freebsd-version and emcc -dumpversion, to detect runtime ABI variants. It reads documented CARGO_CFG_* variables and optional RUST_LIBC_UNSTABLE_* opt-in env vars. All output is confined to cargo:rustc-cfg= and cargo:rustc-check-cfg= directives on stdout; there are no network calls, no filesystem writes, and no side effects outside the Cargo output protocol. This justifies has-build-exec, build-exec-safe, build-exec-no-network, build-exec-no-write-out, build-exec-deterministic, and build-exec-minimal.
The source code consists almost entirely of declarations. The only active code is the inline helpers implemented through the f! and safe_f! macros in src/macros.rs, all of which are straightforward bit-manipulation or pointer-arithmetic expressions (constant shifts, masks, pointer offsets) that correspond directly to C preprocessor macros. No network, filesystem, process, environment, crypto, concurrency, JIT, or interpreter usage was found in any source file, justifying uses-network, uses-filesystem, uses-exec, uses-environment, uses-crypto, uses-concurrency, uses-jit, and uses-interpreter. The crate implements no algorithms, data structures, parsers, protocols, crypto, JIT, or interpreter, justifying all impl-* claims as false. uses-unsafe is justified by 228 occurrences across FFI declarations and inline helpers. is-benign is justified: no obfuscated code, base64 blobs, telemetry, or suspicious network endpoints were found.
Unit tests exist in src/macros.rs (6 tests for c_enum! and offset_of!) and tests/const_fn.rs (compile-time const evaluation check for CMSG_SPACE), justifying has-unit-tests. No integration, fuzz, or property tests were found, justifying has-integration-tests, has-fuzz-tests, and has-property-tests.
No findings were recorded.
Conclusion
libc 0.2.186 is a large but structurally simple crate: declarations, constants, and C-macro equivalents, with one optional build dependency and no runtime I/O. The build script performs version detection only and stays within the Cargo output protocol. The published contents match the VCS commit byte-for-byte (excluding Cargo normalization). The unsafe surface is pervasive but consists of FFI declarations and pointer-arithmetic helpers, which was not exhaustively reviewed under the scoped audit methodology.