id: ffi-09 original_id: P.UNS.FFI.09 level: P impact: MEDIUM Use References Instead of Raw Pointers When Calling Safe C Functions Summary When wrapping C functions that don't need null pointers, use R
阅读全文
Document Invariant Assumptions for C-Provided Parameters
id: ffi-12 original_id: P.UNS.FFI.12 level: P impact: MEDIUM Document Invariant Assumptions for C-Provided Parameters Summary When receiving parameters from C, document what invariants you assume (non
阅读全文
Rule Template
Rule Template Use this template for all unsafe-checker rules. --- id: {prefix}-{number} original_id: P.UNS.XXX.YY or G.UNS.XXX.YY level: P|G impact: CRITICAL|HIGH|MEDIUM clippy: <clippy_lint_name&g
阅读全文
Types Used in FFI Should Have Stable Layout
id: ffi-14 original_id: P.UNS.FFI.14 level: P impact: HIGH Types Used in FFI Should Have Stable Layout Summary FFI types should not change layout between versions. Use #[repr(C)] and avoid types with
阅读全文
Use PhantomData<T> for Variance and Ownership with Pointer Generics
id: ptr-03 original_id: P.UNS.PTR.03 level: P impact: HIGH Use PhantomData for Variance and Ownership with Pointer Generics Summary When a struct contains raw pointers but logically owns or borrows th
阅读全文
Use assert! Instead of debug_assert! in Unsafe Functions
id: safety-11 original_id: G.UNS.SAS.02 level: G impact: MEDIUM clippy: debug_assert_with_mut_call Use assert! Instead of debug_assert! in Unsafe Functions Summary In unsafe functions or functions con
阅读全文
Do Not Expose Uninitialized Memory in Public APIs
id: safety-03 original_id: P.UNS.SAS.03 level: P impact: CRITICAL clippy: uninit_assumed_init Do Not Expose Uninitialized Memory in Public APIs Summary Public APIs must never return or expose uninitia
阅读全文
Avoid Double-Free from Panic Safety Issues
id: safety-04 original_id: P.UNS.SAS.04 level: P impact: CRITICAL Avoid Double-Free from Panic Safety Issues Summary Ensure that resources are not freed twice, especially when panics can occur during
阅读全文
Prefer NonNull<T> Over *mut T
id: ptr-02 original_id: P.UNS.PTR.02 level: P impact: MEDIUM Prefer NonNull Over *mut T Summary Use NonNull<T> instead of *mut T when the pointer should never be null. This enables null pointer
阅读全文
Read Documentation Carefully When Using std::ffi Types
id: ffi-02 original_id: P.UNS.FFI.02 level: P impact: MEDIUM Read Documentation Carefully When Using std::ffi Types Summary The std::ffi module has many types with subtle differences. Read their docum
阅读全文