-
-
Notifications
You must be signed in to change notification settings - Fork 138
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
Possible unsoundness in rtc_Bytes::as_slice #60
Comments
and maybe same problem for as_str ringrtc/src/rust/src/lite/ffi.rs Line 127 in 9eec8cf
I'm currently just emulating the program's implementation logic without the clone codebase to actually verify it, so don't mind if this is a false message. |
@lwz23 Thank you for the feedback! |
The suggestion to add From my point of view. Marking If the team has confidence that the Swift-side guarantees will always hold and that this method will not be exposed in less controlled contexts, documenting these safety assumptions might be sufficient. I just think marking the function as |
Description:
The implementation of rtc_Bytes::as_slice is unsound and may lead to undefined behavior (UB) when the count field exceeds the actual allocated size of the memory pointed to by ptr. This occurs because the method uses std::slice::from_raw_parts without validating whether the pointer and length are valid, potentially causing out-of-bounds memory access.
PoC
run with miri
Suggest fix
To ensure memory safety, validate both the ptr and count fields before calling std::slice::from_raw_parts.
The text was updated successfully, but these errors were encountered: