id: io-01 original_id: P.UNS.FIO.01 level: P impact: HIGH Ensure I/O Safety When Using Raw Handles Summary When working with raw file descriptors or handles, ensure they are valid for the duration of
阅读全文
Do Not Modify Memory Variables of Other Processes or Dynamic Libraries
id: mem-02 original_id: P.UNS.MEM.02 level: P impact: CRITICAL Do Not Modify Memory Variables of Other Processes or Dynamic Libraries Summary Do not directly manipulate memory belonging to other proce
阅读全文
Provide Unsafe Counterparts for Performance Alongside Safe Methods
id: safety-07 original_id: P.UNS.SAS.07 level: P impact: MEDIUM Provide Unsafe Counterparts for Performance Alongside Safe Methods Summary When providing performance-critical operations that skip safe
阅读全文
Handle Errors Properly in FFI
id: ffi-08 original_id: P.UNS.FFI.08 level: P impact: HIGH Handle Errors Properly in FFI Summary FFI functions must use C-compatible error handling (return codes, errno, out parameters). Rust's Result
阅读全文
Choose Appropriate Data Layout for Struct/Tuple/Enum
id: mem-01 original_id: P.UNS.MEM.01 level: P impact: HIGH Choose Appropriate Data Layout for Struct/Tuple/Enum Summary Use #[repr(...)] attributes to control data layout when interfacing with C, doin
阅读全文
Use Dedicated Opaque Type Pointers Instead of c_void for C Opaque Types
id: ffi-17 original_id: P.UNS.FFI.17 level: P impact: MEDIUM Use Dedicated Opaque Type Pointers Instead of c_void for C Opaque Types Summary Instead of using *mut c_void for opaque C handles, create d
阅读全文
Do Not Dereference Pointers Cast to Misaligned Types
id: ptr-04 original_id: G.UNS.PTR.01 level: G impact: HIGH clippy: cast_ptr_alignment Do Not Dereference Pointers Cast to Misaligned Types Summary When casting a pointer to a different type, ensure th
阅读全文
Ensure C-ABI Compatibility for Strings Between Rust and C
id: ffi-06 original_id: P.UNS.FFI.06 level: P impact: HIGH Ensure C-ABI Compatibility for Strings Between Rust and C Summary When passing strings across FFI, ensure both sides agree on encoding, null-
阅读全文
Use MaybeUninit<T> for Uninitialized Memory
id: mem-06 original_id: G.UNS.MEM.01 level: G impact: HIGH clippy: uninit_assumed_init, uninit_vec Use MaybeUninit for Uninitialized Memory Summary Use MaybeUninit<T> instead of mem::uninitializ
阅读全文
Do Not Use Union Variants Across Different Lifetimes
id: union-02 original_id: P.UNS.UNI.02 level: P impact: CRITICAL Do Not Use Union Variants Across Different Lifetimes Summary Do not write to one union field and read from another field that has a dif
阅读全文