2 ms·
> You could write equivalently bad code in any language that supports array types, and get similarly broken results. You wouldn't get "similarly broken results
by Someone1234 8y ago
> You could write equivalently bad code in any language that supports array types, and get similarly broken results.
You wouldn't get "similarly broken results." The results for doing this in C/C++ are far more serious, which was a point the article made.
If you do this in Rust/C#/Java/etc they will safely crash. If you do this in C/C++ it is undefined behavior, it may crash, but it also could allow remote code execution.
The Rust version of this bug is Security-Low (crash), the C++ version is Security-Critical (potential RCE).
- ec109685 8y agoIf you want to prevent this class a bugs, you don’t need to switch languages is the point. Run a linter that prevents that syntax.
- hedora 8y agoRight, but all you have to do in C++ is switch the array implementation to bounds check by default. This is not rocket science, and is certainly easier than rewriting large code bases from scratch. Similarly, I could complain that rust arrays are too slow, and produce an array implementation that uses unsafe under the covers.
- steveklabnik 8y agoDropbox did this in their Rust code: https://github.com/dropbox/rust-brotli-decompressor/blob/master/src/memory.rs#L71-L76 https://github.com/dropbox/rust-brotli-decompressor/blob/mas... https://github.com/dropbox/rust-brotli-decompressor/blob/master/src/memory.rs#L18-L23 https://github.com/dropbox/rust-brotli-decompressor/blob/mas... Toggle the feature, remove the bounds checks unconditionally.