-
Notifications
You must be signed in to change notification settings - Fork 667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ucontext creates reference to uninitialized memory #1092
Comments
Also, Ucontext appears to be untested. |
That shouldn't be a problem. The value is only uninitialized until it gets initialized two lines lower. Or is there something else I'm missing? |
If one uses The easiest safest way of creating an uninitialized or zero-initialized Since union MaybeUninit_ { x: ucontext_t, y: () }
// initialize the storage of ucontext_t to uninitialized, while initializing the union:
let mut context = MaybeUninit_ { y: () };
// create a raw pointer to ucontext_t without creating a reference to it:
let ptr = &mut context as *mut _ as *mut ucontext_t;
// ...use ptr...
// Once ucontext_t properly initialized, pull it out
let context = unsafe { context.x }; |
Closing in favor of #1096 . |
See
nix/src/ucontext.rs
Line 17 in 50f55e7
You probably want to use
mem::zeroed()
here.Note also that newer
ucontext_t
have a shadow stack field that's not available in older versions. Since theucontext_t
struct becomes larger, this should be able to work in a backward compatible way.The text was updated successfully, but these errors were encountered: