strncpy() isn't insecure, but rarely the function you want to use. In most cases...
Harry Sintonen @harrysintonen@infosec.exchange
strncpy() isn't insecure, but rarely the function you want to use. In most cases, you don't want to fill the whole buffer with zeros. Also, in most cases, you probably want to terminate the resulting string with a null terminator, in all cases where there is room for the terminator.
It is true that many people get strncpy() wrong, especially the return value and the behaviour when the input string is longer than the output buffer size.
So yes, it is best to avoid strncpy(). But claiming strncpy() to be insecure is wrong. strncpy() is perfectly secure if used correctly.