notorandit 22 minutes ago

That bug was a programmers' bug.

No language would have prevented it to happen.

And even if it was a memory safety bug, that would have been a programmers' bug.

C has no issues with memory as it let's programmers do what they want.

PeterWhittaker 1 day ago

This is less a problem with C and more a bad design decision by the musl team. In response to poor practices (programmers not checking what crypt returned), they built an arguably worse one (returning a sentinel value).

Sure, Rust's std::result can make it harder to dumb, but dumb can always find a way.

  • sunshowers 1 day ago

    From the post:

    > You can very well write a Rust function that returns "*" if the password is too long. But the big difference between C and Rust in this regard is that the norms of the Rust community do not allow that.

    • xscott 1 day ago
      • kushudai 1 day ago

        Whataboutery generally makes it quite clear that your arguments are not in good faith.

        • xscott 1 day ago

          There's a difference between whataboutism and calling out hypocrisy, but those are on a spectrum. However, using a sock puppet (or two?) is clearly in bad faith.

          Even though it's been beaten to death, I think there are still interesting discussions to be had about the problems in C, possible solutions to those, and which ones Rust provides at what cost. Really, I wish we had a few more options in the "memory safe languages without a garbage collector" space. However, junior evangelists who make themselves feel safer by finger pointing aren't likely to add much value to the conversation.

          This particular post is unusual, because it's not even about a flaw in C. Appealing to Rust's culture and norms isn't compelling to me, and it will be insufferable if the newbies start regularly trotting out this nonsense.

          I pasted that link to show that Rust doesn't save you from logic errors. I think the best way to get better at programming is to keep doing it while learning from mistakes. I think the best way to proselytize Rust is to finish and deliver good software with it.

          • sunshowers 1 day ago

            > I think the best way to proselytize Rust is to finish and deliver good software with it.

            I think you might want to look up my body of work, and also lay off on the baseless accusations of sockpuppetry.

            • xscott 22 hours ago

              I think people should be proud of their work and humble about its importance. In most circumstances, I don't like to criticize things people create and give away for free, but since you invited, MUSL is more significant and valuable to me.

      • opliko 22 hours ago

        Do you... Do you think this is similar in severity, impact, or even implementation stupidity to *sshhole?

        Or is your point just "see? Rust doesn't prevent all stupid errors!".

        And yes, *sshhole is a C language problem, even if you technically can achieve it in Rust just like you technically can still write memory vulnerabilities in any memory safe language if you try hard enough. The point is that any more modern language has learned that there are several behaviors where the easy way that's typically taught should be fail-safe. Enforcing error handling is one of these. Zig didn't get on the memory safety train, but it absolutely did on get to error unions. Basically every language that's trying to be a C successor in any way is doing that. Because it turns out the "standard" C error handling and the ways that posix and libraries have traditionally done just sucks and results in idiocy like this. Even languages like Java at least realized that with try/catch there needs to be some way to enforce error handling downstream (not to say there aren't other languages that don't promote that! You won't find me defending JS on this issue for instance)

        Now, can you do errors better in C? Sure you can! It may be a bit more cumbersome, generate a lot more code, and be a bit of a pain in the ass to do, but you absolutely could if you wanted to. Do you know any large popular C codebase that does though? I don't. Returning NULL or errno or -1 is what's commonly done and what most learning materials about C will tell you to do. It's the UNIX convention. Using a sentinel value for errors is just what's done in C and yes, it works just fine most of the time.

        But as the post says: this is the issue. C as a language, as a set of standards, as community around them, just treats all of this a skill issue, ignoring that it is possible to increase the safety by making it more convenient to write safe code, because it's not possible to magically get rid of all issues away so why should we bother at all.*

        • xscott 22 hours ago

          I don't know which of your questions are sincere vs rhetorical. Maybe the one about C codebases is genuine: OpenBSD aims for security through correctness, although it's limited in popularity.

          If you actually wanted an answer to any of the others, and maybe if you can calm down a little, I'd be happy to tell you my thoughts.

    • PeterWhittaker 1 day ago

      Yeah, read that, laughed. While the statement may have some truthiness, if one flips it around it is basically saying that the norms of musl community allow programmers to be extra dumb.

      Taking a different perspective, there are two intertwined thoughts in the original article and in most comments: 1) language safety, 2) community safety.

      Each needs to assessed on its own.

thradams 1 day ago

Memory safety is something that can be added to C. For instance, Cake in safety mode requires explicit handling of potentially null return values.

http://cakecc.org/playground.html?code=I2luY2x1ZGUgPHN0ZGlvL...

Most of the problems described in Rust manuals as things C cannot prevent, such as memory leaks, double frees, and use-after-free, can be detected at compile time in Cake with very few annotations.

  • bestouff 15 hours ago

    That's RAII for you and that's the easy part. Rust has so much more safety features C can't even dream of having. Its type system for a start.

MarkusWinand 14 hours ago

> The engineering norms of C developers allow for "*" to be an acceptable sentinel value indicating an error[...]

No. Just No. It's not.

varispeed 1 day ago

What does it have to do with C? It's just poor design.

It's like blaming poor driving on one's tracksuit.

  • sunshowers 1 day ago

    I think if you read the post you will find the answer to your question.

    • varispeed 1 day ago

      I did read it. Again, it is blaming poor engineering on C. It's almost like saying people are e.g. stealing because they belong to certain socio-economic group. Crass.

      • viraptor 1 day ago

        No, this makes sense. You often see people avoid a good solution in early languages, because it's harder to implement. This impacts security, performance, and overall design.

        Consider how much easier it is in rust to do tagged unions that won't have the same pitfalls as C's, how much more likely you are to use a rust map from std rather than custom / imported dependency to do that in C, how much more likely you are to do real Unicode processing in rust vs treating strings as opaque bytes and hoping for the best in C. These are things that happen all the time. We can improve design and engineering a lot by simply providing an easy way to get it implemented.

        The first time you need a string map in an existing C code, it's often "an event". Do you spend time rolling your own? Do you include a library? How big - are you pulling the whole glib? Do the strings need fancy locale aware comparison? Do you simplify, take a performance hit, and just scan an array instead?

        A lot of the time when there's a logic bug and people comment "that's not a memory safety issue, Rust wouldn't protect from it", it's true, but I also think: "but this issue wouldn't exist because enum/type matching would stop it".

    • card_zero 1 day ago

      It says "the norms of the Rust community" would prevent this vulnerability. So, it's about habits. The terms Rust and C in fact refer to habits.

      • sunshowers 1 day ago

        There are two big differences between norms and habits: habits are usually individual while norms apply to a community, and norms have a great deal of social pressure behind them.

        • card_zero 1 day ago

          That's true. I just didn't want to keep saying norm because somebody might ask "who's Norm?".

  • goalieca 1 day ago

    I could see the same thing in Python. Except instead it would be an inhandled none they didn’t like so they would return a *.

  • anotherhue 1 day ago

    If safety features are available and you choose not to use them then that's bad engineering.

    I love K&R as much as the next guy but special magic ASCII chars multiply defined by convention over 40 years is exactly the sort of rubbish a good type system can protect against (if used).

0xbadc0de5 1 day ago

Except *sshole isn't a memory safety vulnerability - it's a logic bug. And logic bugs happen in every programming language.

  • aw1621107 1 day ago

    Yes, this is explicitly discussed in the post:

    > This is not a memory safety vulnerability; rather, it is one of those issues that, people often say, languages with better type systems won’t save you from. This is true! You can very well write a Rust function that returns "" if the password is too long. But the big difference between C and Rust in this regard is that the norms of the Rust community do not allow that.*

  • Techcable 17 hours ago

    It is idiomatic C to use in-band sentinel values (NULL is the most prominent example). It is very much not idiomatic rust.

    • 1718627440 5 hours ago

      It's also idiomatic in C to use the return value solely for sentinels and pass the actual result in an output variable.

johnea 22 hours ago

Never

The authors obviously don't do small embedded s/w dev.

Additionally, this is part of a trend that expects the library to do a large part of the application development.

zeroCalories 1 day ago

I just really hate rust compile times man

whatthejesus 1 day ago

Oohhh there’s one more C vulnerability. Oh my gosh, what ever will I do? Should I buy a new smart toaster? I’m not sure. I just really don’t know what to do right now.

It’s called pay attention and f*king upgrade your packages.