The strndup() function shall return a malloc()'d copy of at most n bytes of string. The resultant string shall be terminated even if no NULL terminator appears before string+n.
On success, strndup() shall return a pointer to a newly
allocated block of memory containing a copy of at most n
bytes of string. Otherwise, strndup()
shall return NULL and set
to indicate the error.