Not every C vuln is a memory safety problem.
[–] realharo 3 days ago
In Rust, the type of the return value would be a `Result<T, E>`, which means the chain of events that led to this would never have started in the first place.
[–] my-huge-pony 3 days ago
Edit: at the beginning, crypt always returned a value. So hypothetical Rust return type would be a String, and then it would be retained for backward compatibility. Or something else would happen, this is a complex logic bug triggered by a 25 year old chain of events.
[–] realharo 3 days ago
That's what led some people to write code where it crashes without checks. Which is still their mistake. But if the type was something that can't be implicitly used like an always-present value, that would have prevented the situation, even with those same people.
[–] uecker 2 days ago
[–] realharo 1 day ago
Trying to change a function return type from e.g. `string` to `string?` would make the backwards-incompatible breaking change immediately visible, and break the builds of all code that relied on not having to check it back when it was `string` - at compile time.
[–] uecker 1 day ago
But it turns out one can have a compile-time error forthis in C as well: https://godbolt.org/z/8E9z66cfs
[–] atomicUpdate 2 days ago
[–] Gibbon1 2 days ago
You are right, C with manual memory management, no lifetime management, lack of phat pointers and a culture of leet has problems with deranged maddening bugs that other languages don't have.
But this bug first shows how inband signaling is bad news usually. But worse it's a failure to adhere to the spec properly. If you implement a library and you don't adhere to the spec you're going to bone someone.
Perhaps even worse is obviously the spec doesn't come with any standard testing framework. That was also the root of Apples infamous goto bug.
[–] bmacho 3 days ago
Easier to formulate invariants and check/prove them. Better language correlates with safer software.
[–] slopinthebag 3 days ago
oh right, because c is a crusty old language with barely any features.
[–] rhdjebejdbd 3 days ago
[–] ethin 3 days ago
[–] K0nserv 3 days ago
Now, the decision to return `"*"` instead of letting poorly written code crash on `NULL` is not good either.
[–] pheggs 2 days ago
[–] _flux 2 days ago
Given how easy it is to just forward that error to the caller, I think most Rust developers would just choose to do that.
[–] uecker 2 days ago
[–] K0nserv 2 days ago
That's exactly what you get with Result and Option, it's impossible to forget.
Compare:
To:[–] pheggs 2 days ago
[–] K0nserv 2 days ago