Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
uplink: Fix passing dangling stack pointer
There were 2 bugs in the `register_gateway_access()` code: 1. Most prominently, the function was constructing and passing a dangling pointer to a temporary `EdgeRegisterAccessOptions` to the FFI. In fact, that variable doesn't even live to the point that the FFI is made. While this occurs on the stack and may not always be overwritten, the compiler and program is free to reclaim and reuse that stack space for other things -- it's technically UB. This code is somewhat lucky that this doesn't occur very often because the struct is very small, on the stack, and a boolean. 2. The function was also casting the `*const EdgeRegisterAccessOptions` pointer as mutable in the unsafe block, which violates Rust's aliasing guarantees and can potentially lead to undefined behavior.
- Loading branch information