It prints out "12345". The fact that it prints out the entire string means the string termination character is stored...where? The documentation for strncpy() states:
????No null-character is implicitly appended at the end of destination if source is longer than num. Thus, in this case, destination shall not be considered
????a null terminated C string (reading it as such would overflow).
Moral: The strn*() function don't guarantee? protection against buffer overflow. It simply means you're thinking about it.
Jack, W8TEE
On Thursday, July 5, 2018, 8:56:00 AM EDT, Brian Bowling <bowlingb@...> wrote:
How about making your programming safer and more robust? ?Strcat() and strcpy() can be found at the root of so many buffer overflows. If you must use them at least use the 'n' versions strncpy() and strncat().?