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
I am concerned that there may be potential unsound problems here, json_interface is a pub mod, StringData is a pub struct, and content is a pub field. I take this to mean that an external user can call and modify the content field directly, and that to_string calls from_raw_parts without any checking, which I fear could lead to a potential UB (eg.null pointer), So I thought maybe it would be a more appropriate choice to
mark to_string as unsafe or
make these fields and functions private if there is no external use.
The text was updated successfully, but these errors were encountered:
PS E:\Github\lwz> cargo run
Compiling lwz v0.1.0 (E:\Github\lwz)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.52s
Running `target\debug\lwz.exe`
thread 'main' panicked at core\src\panicking.rs:223:5:
unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
error: process didn't exit successfully: `target\debug\lwz.exe` (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN)
It seems that you don't even need to manually modify the content field, just use the provided default function to trigger UB.
Hello, thank you for your contribution to this project. I'm currently scanning rust projects for unsound issues, and I notice the following code.
I am concerned that there may be potential unsound problems here,
json_interface
is apub
mod,StringData
is apub
struct, andcontent
is apub
field. I take this to mean that an external user can call and modify thecontent
field directly, and thatto_string
callsfrom_raw_parts
without any checking, which I fear could lead to a potential UB (eg.null pointer), So I thought maybe it would be a more appropriate choice toto_string
asunsafe
orprivate
if there is no external use.The text was updated successfully, but these errors were encountered: