5 ms·
One day we'll get strlcpy and strlcat for sure. Just not here, not now.
by beefhash 12y ago
One day we'll get strlcpy and strlcat for sure. Just not here, not now.
- nly 12y agoThey're in libbsd, which is a dependency of Samba and therefore installed on most desktop distros. They just trade off one bug for another anyway.
- __david__ 12y agoOr the C11 safe string functions. It depresses me that they aren't already there...
- fafner 12y agoThe C11 safe string functions suffer from the fact that the error handling depends on a global state. The default states can either abort the application or make the functions return an error indicator. But IIRC the user can provide anything else for error handling as well. Therefore using them in a library comes with the risk of those functions handling errors different than you expected. Using them in the application comes with the risk of some library messing with it. That's why many people are opposed to them.
- _delirium 12y agoUnfortunately the C11 safe string functions are part of an optional annex to the standard, not the standard per se, so are only quasi-standard. Afaik only Microsoft's standard library supports them, and other vendors have some skepticism about the design.
- stephencanon 12y agoDon’t use implicit length strings at all. Use one of the various better string libraries, or use explicit length + buffer representations with memcpy and friends. Safer and faster than any of the “safe” string APIs.