← Back to context

Comment by saagarjha

2 years ago

I guess you are right and my actual annoyance is that people are using this function and I don’t think they should in many cases. I would’ve liked the function to mostly fade from use and not be standardized as a result…

Let this be a warning of what happens when the (g)libc folks refuse to consider programmer needs and offer no solution. Had glibc offered any semi-sane solution, they'd have won by marketshare alone and their solution would have been used everywhere instead. By the time Linus thought of strscpy, it was too late.

>'We want a semi-sane null-terminated string copy function'

>'All you need is memccpy, la-la-la'

>(Everybody runs away screaming, even the Linux kernel folks decides to create a string function)

>(OpenBSD has a ready solution and a decent enough reputation, almost nobody checks it)

>Versions of strlcpy are embedded everywhere.

>glibc is forced to implement strlcpy.