logoalt Hacker News

my-huge-pony • today at 5:12 PM • 4 replies • view on HN

How would using a language different than C help here? At it's core this bug is a logic bug, where "*" == crypt(x), because crypt in musl started returning "*" in some cases some years ago. This could be Rust. This could be Go.

Not every C vuln is a memory safety problem.


Replies

rhdjebejdbd • today at 5:17 PM

Another comment said that returning a * was to avoid returning null which would crash users of the library who didn't check for null. That seems like a C smell to me

➕ show 1 reply
realharo • today at 5:16 PM

>because crypt in musl started returning "*" in some cases some years 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.

➕ show 2 replies
bmacho • today at 5:58 PM

> How would using a language different than C help here?

Easier to formulate invariants and check/prove them. Better language correlates with safer software.

slopinthebag • today at 5:17 PM

why does this logic bug exist? why are they returning a string, why not a result type, (nil, err), or something else?

oh right, because c is a crusty old language with barely any features.