Ideas: strlcpy(3)
The strlcpy() and strlcat() functions copy and concatenate strings re- spectively. They are designed to be safer, more consistent, and less error prone replacements for strncpy(3) and strncat(3). It only copies as much as needed, up to a limit (with a guarantee of NUL termination to boot, unlike strncpy()). strncpy will continue to write 0's after the end of the string, up to the limit, so strncpy(a,"b",1048576) will write almost 1MB of zeroes while strlcpy does the minimum memory traffic needed.
- strncpy(z_suffix, Z_SUFFIX, sizeof(z_suffix)-1); + strlcpy(z_suffix, Z_SUFFIX, sizeof(z_suffix)); - strcat(ifname, "."); + strlcat(ifname, ".", sizeof(ifname));