strncpy supposedly protects from buffer overflows. But if it prevents an overflow without null terminating, in all likelyhood a subsequent string operation is going to overflow. So to protect against this I find myself doing
strncpy( dest, src, LEN );
dest[LEN-1] = '\0';
man strncpy:
The strncpy() function is similar, except that not more than n bytes of src are copied. Thus, if there is no null byte among the first n bytes of src, the result will not be null-terminated.
Without null terminating something seemingly innocent like
printf( "FOO: %s\n", dest );
Could crash.
So are there better alternatives?