Hi,

As I have been working on upgrading OSv (https://github.com/cloudius-systems/osv) to latest version of musl, I have noticed that both network/if_nametoindex.c and network/if_indextoname.c use strncpy() to copy interface name to/from buffer. In both cases per https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/net_if.h.html and https://linux.die.net/man/3/if_indextoname, it seems that  ifname should be big enough to hold IF_NAMESIZE bytes which SHOULD include null terminating one. If that is the case both functions should use strlcpy instead of strncpy.

Am I wrong?

My regards,
Waldemar Kozaczuk

PS. Trying to compile if_nameindex() yields warning:

  CC musl/src/network/if_nameindex.c
include/api/net/if.h: In function ‘if_nametoindex’:
musl/src/network/if_nametoindex.c:14:2: error: ‘strncpy’ specified bound 16 equals destination size [-Werror=stringop-truncation]
   14 |  strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name);