The Most Memory Safe Buffer Overflow in Rust
gist.github.com
gist.github.com
* an untyped, unchecked region of memory is modeled by `let mut mem = Vec::<char>::new();`
* First, a fixed range of 16 bytes in mem is allocated for the password to be read
* Then the password to check against is allocated and stored in mem
* Then the input with embedded `'\0'`s is read into the range, without respecting the BUF_CAP
* Finally, the two regions within `mem` are compared for string equality
There were no unsafe operations, but an "undesired" result can occur.It could be more interesting to have another buffer holding user input and then overflow it and corrupt the password buffer.
I am curious if that is possible without using unsafe?