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 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.
0 commit comments