#include <pcp/pmapi.h>
int pmstrncpy(char *dest, size_t destlen, char *src);
cc ... -lpcp
pmstrncpy is safe string copying routine with semantics similar to strncpy(3).
The main differences between pmstrncpy and strncpy(3) are:
On success, pmstrncpy returns 0, else -1 indicates that src is too big and the result been truncated to ensure dest has not been overrun.
strncpy(3) first appeared in Edition 7 AT&T Unix around 1979. It was specifically crafted to copy file names from component names from on-disk directory entries that were of a fixed maximum size and may have zero, one or more trailing null-bytes
The subsequent attempts to use strncpy(3) for more generally string copying operations has been fraught with abuse and security issues; pmstrncpy is an attempt to address these problems.
PMAPI(3), pmstrncat(3), strncat(3) and strncpy(3).