News for hackers. Stuff that matters.
Re:C String Creation by kevin_thibedeau on Thursday February 11, 2016 @08:25PM (#11084719)
I see too much damage caused by strncpy() to ever recommend it for use. Code that is blissfully unaware of the non-guaranteed NUL or that repetitively does extra work to guarantee a NUL. Use strlcpy() if available or reimplement it.
Re:C String Creation by sortie on Friday February 12, 2016 @02:54AM (#11085856)
As in the article, strncpy has valid uses, but it's widely misunderstood due to the poor name. strlcpy is what the name suggests. People are also surprised by the zero padding.