News for hackers. Stuff that matters.
Re:Beware of strncpy and strncat by MrBingley on Wednesday June 06, 2018 @02:04PM (#17249465)
Looking at the comments in this post, I'm resigning myself that there simply is no correct solution for copying or concating strings in C. Null-terminated strings are a fundamentally broken concept. I think the long-term solution is simply to move to a different language (Rust, C++, D, Go, whatever) where we have the benefit of hindsight and have (pointer, length) string types, which solve all the problems null-terminated strings introduce.
Re:Beware of strncpy and strncat by blub on Wednesday June 06, 2018 @03:26PM (#17250244)
It's quite sad to behold how hard it is to work with strings in C.

All those functions seem broken by design, forcing the programmer to clean up their mess in edge cases.

Re:Beware of strncpy and strncat by mjevans on Wednesday June 06, 2018 @03:13PM (#17250132)
You could also validate on interface transition and use your own type internally; which is often what happens when using another language and exporting C style library bindings.