3 ms·
> Writing the implementation in Rust does sigh, not true. https://tgrez.github.io/posts/2022-06-19-buffer-overflow-in-rust.html https://tgrez.github.io/posts/
by fallat 4y ago
> Writing the implementation in Rust does
sigh, not true.
https://tgrez.github.io/posts/2022-06-19-buffer-overflow-in-rust.html https://tgrez.github.io/posts/2022-06-19-buffer-overflow-in-...
https://shnatsel.medium.com/how-rusts-standard-library-was-vulnerable-for-years-and-nobody-noticed-aebf0503c3d6 https://shnatsel.medium.com/how-rusts-standard-library-was-v... "This is a buffer overflow bug in the standard library’s implementation of a double-ended queue."
"Rust will panic if you attempt to write out of bounds."
Writing the implementation will increase memory safety but only if the implementation adheres strictly to safe Rust - which means even avoiding ANY packages that use unsafe features. The fact Rust can pull in any package that has an unsafe {} block means you're not promised to be safe.
The equivalent could be said about writing the implementation in JavaScript, Python, etc... (that they protect against buffer overflows)
- sevenoftwelve 4y agoGranted, writing things in Rust doesn't exclude the possibility of a buffer overflow entirely. It does help make it much less likely.
- fallat 4y agoYes, I mentioned it :)
- witrak 4y agoSo any claim such as your previous one is rather of no value. >It does help make it much less likely. Yeah... To the same extent as the infamous proof of formal correctness of an example program published in a book, until the program was tested negatively by a student some months later.
- chlorion 4y agoPanicking when writing out of bounds is not a bad thing though, this is the behavior you want, assuming you can't statically guarantee that indexes are always in bounds. It is true though that the underlying unsafe rust in std, or crates or whatnot can have errors though and sometimes we just kind of pretend it's not there since we don't see it. >The equivalent could be said about writing the implementation in JavaScript, Python, etc... (that they protect against buffer overflows) This is why we should be encouraging people to write in memory safe languages in general and not just rust or whatever. The overwhelming majority of software does not need to be some super optimized native-code SIMD+AVX1024 beast and would run on something like .net or the JVM, and even Python with no issues. It makes me cringe every time I see some random utils written in C that would work fine in Python.