by omeid2 · 2y ago · 0 comments
I find it almost inexcusable at this point.
*Shrug* Some people prefer simplicity.
> I find it almost inexcusable at this point.
C has been deployed, since the 80s, in millions upon millions of life-critical systems with loss of human life due to C-specific errors close to zero.
It's fascinating that you think that, until Rust (or modern C++ came along), people were being killed in significant numbers due to C-specific errors.
There is no need for it. Rust already has libraries for http, websockets, and mqtt.
> This one has 13 years proven battlefield use. And by lord this myth of "Old therefore must be battle-tested" must die.
Case in appoint, I had to interact with a piece of software that used this library and it is as battle-tested as expecting HTTP headers in very specific casing!
Here is a comment from some code I wrote circa 2020 to deal with this issue. So it is not hypothetical.
// libwebsocket/1.X.X is naive about http headers
// and expects them in a specific case but node.js as
// permitted by http spec doesn't care about case.
// this patches node.js http to send headers as expected
// by libwebsocket/VAA
const { setHeader } = http.OutgoingMessage.prototype;
http.OutgoingMessage.prototype.setHeader = function (name, value) {
name = name
.replace(/\b(\w)/g, (match, submatch) => (submatch ? submatch.toUpperCase() : ''))
.replace(/(websocket|Websocket)/g, () => 'WebSocket');
value = value.replace(/(websocket|Websocket)/g, () => 'WebSocket');
setHeader.call(this, name, value);
};>> Rust may have safe memory coding built-in, it doesnt guarantee the coding to be 100% bug free or fully secure from zero day attacks.
> Case in appoint, I had to interact with a piece of software that used this library and it is as battle-tested as expecting HTTP headers in very specific casing!
How would rewriting in $SOMETHING_OTHER_THAN_C help with this bug? This is a bug that would have happened in any language.
After all, Gow8876 was very specific about what he was referring to ("memory safety" bugs), because you were very specific about what you were referring to ("unsafe language").
I pointed out this defect because handling HTTP headers "correctly" is such a basic requirement for a websocket library, yet it failed at it, so the claim for "13 years proven battlefield use" is baseless and only based on the fallacy of "it is old therefore battle-tested".
> Rust may have safe memory coding built-in, it doesnt guarantee the coding to be 100% bug free or fully secure from zero day attacks.
No one is making this absurd claim, but what we know is that majority of RCE bugs are memory related.
And because C is more popular in embedded, new vendors are more likely to pick it for new platforms instead of Rust, which doesn't help.
It is still quite common to see proprietary compiler-suites in the embedded world.
Most only support C. Some do not even support C99 :)
Sure for many ARM targets (e.g. Cortex series), you can use GCC or LLVM etc. and get access to C++.
Many embedded shops targetting the lower end (8-32 bit CPUs <100MHz + 8-32kb RAM) prefer C for the simplicity.
1: STMicro announced back in 2016 that they’d sold more than 2 billion of these chips, so it’s not some obscure little niche processor.
You can _only_ use it anywhere you can use Linux, BSD, or FreeRTOS, which also means you can use C++ and Rust.
In addition there are tiny microcontrollers (8051/AT89, STM32 etc)
Essentially these are Platforms with
1. Very specific instruction set (DSPs) 2. extremely limited resources 3. specialized toolchain and no LLVM support
C isn't great, but at least it's relatively simple and is well understood.
What you're suggesting is a nightmare scenario.