aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/mach
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/mach')
-rw-r--r--sysdeps/mach/hurd/if_index.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sysdeps/mach/hurd/if_index.c b/sysdeps/mach/hurd/if_index.c
index d637353..7f647b7 100644
--- a/sysdeps/mach/hurd/if_index.c
+++ b/sysdeps/mach/hurd/if_index.c
@@ -37,7 +37,9 @@ __if_nametoindex (const char *ifname)
if (fd < 0)
return 0;
- strncpy (ifr.ifr_name, ifname, IFNAMSIZ);
+ strncpy (ifr.ifr_name, ifname, IFNAMSIZ - 1);
+ ifr.ifr_name[IFNAMESIZ - 1] = '\0';
+
if (__ioctl (fd, SIOCGIFINDEX, &ifr) < 0)
{
int saved_errno = errno;