You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are places in the current Rust bindings where the FFI glue wraps underlying C++ function calls in unsafe blocks, then casts the response to an expected type, ignoring potential error codes from the original API.
This example neither checks the global errno value, nor that the return value of the underlying C++ method is negative, which means that calls that error simply return the result of a (bogus) i32 -> usize cast.
We should audit this interface and look for cases where we're potentially doing unchecked casts, minimize use of unsafe, and (eventually) separate the low-level FFI into a dedicated libzt-sys crate with a safe, hardened Rust interface in this library.
The text was updated successfully, but these errors were encountered:
There are places in the current Rust bindings where the FFI glue wraps underlying C++ function calls in
unsafe
blocks, then casts the response to an expected type, ignoring potential error codes from the original API.Example:
libzt/pkg/crate/libzt/src/socket.rs
Line 223 in 8d21a26
This example neither checks the global
errno
value, nor that the return value of the underlying C++ method is negative, which means that calls that error simply return the result of a (bogus) i32 -> usize cast.We should audit this interface and look for cases where we're potentially doing unchecked casts, minimize use of
unsafe
, and (eventually) separate the low-level FFI into a dedicatedlibzt-sys
crate with a safe, hardened Rust interface in this library.The text was updated successfully, but these errors were encountered: