3 ms·
A reminder that we've had strlcpy[1] for ~ 30 years but it was never accepted into the Linux world because of typical petty open source bullshit. This is why we
by naturalmovement 4mo ago
A reminder that we've had strlcpy[1] for ~ 30 years but it was never accepted into the Linux world because of typical petty open source bullshit. This is why we can't have nice things.
[1] https://man.openbsd.org/strlcpy https://man.openbsd.org/strlcpy
- BoingBoomTschak 4mo agoActually, glibc 2.38 has it.
- naturalmovement 4mo agoWow it only took them 26 years to import a 30 line C function, a third of which is comments? I should have sent them a nice fruit basket to commemorate the occasion.
- ericbarrett 4mo agoThe Linux kernel had strlcpy over 20 years ago. It was removed in favor of strscpy because the latter was judged a better interface. Here's a 2022 article: https://lwn.net/Articles/905777/ https://lwn.net/Articles/905777/
- avadodin 4mo agoReturning an error is better but you're using ssize_t which is a tradeoff. The race conditions appear to be a result of the Linux kernel implementation but UNIX style syscalls introduce these races by default. It is not an inherent flaw of the API or even the implementation Linux was using. The only useable C string API has always been memcpy anyways.