minissdpd/getifaddr.c: update

see 585a1d64e2
This commit is contained in:
Thomas Bernard 2019-08-24 11:06:49 +02:00
parent 6317e73342
commit c4b31a1fca
1 changed files with 7 additions and 5 deletions

View File

@ -1,8 +1,8 @@
/* $Id: getifaddr.c,v 1.25 2018/07/06 11:47:29 nanard Exp $ */
/* $Id: getifaddr.c,v 1.26 2019/05/20 19:54:08 nanard Exp $ */
/* vim: tabstop=4 shiftwidth=4 noexpandtab
* MiniUPnP project
* http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
* (c) 2006-2018 Thomas Bernard
* (c) 2006-2019 Thomas Bernard
* This software is subject to the conditions detailed
* in the LICENCE file provided within the distribution */
@ -47,7 +47,7 @@ getifaddr(const char * ifname, char * buf, int len,
syslog(LOG_ERR, "socket(PF_INET, SOCK_DGRAM): %m");
return -1;
}
strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
strncpy(ifr.ifr_name, ifname, IFNAMSIZ-1);
ifr.ifr_name[IFNAMSIZ-1] = '\0';
if(ioctl(s, SIOCGIFFLAGS, &ifr, &ifrlen) < 0)
{
@ -61,7 +61,8 @@ getifaddr(const char * ifname, char * buf, int len,
close(s);
return -1;
}
strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
strncpy(ifr.ifr_name, ifname, IFNAMSIZ-1);
ifr.ifr_name[IFNAMSIZ-1] = '\0';
if(ioctl(s, SIOCGIFADDR, &ifr, &ifrlen) < 0)
{
syslog(LOG_ERR, "ioctl(s, SIOCGIFADDR, ...): %m");
@ -81,7 +82,8 @@ getifaddr(const char * ifname, char * buf, int len,
}
if(mask)
{
strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
strncpy(ifr.ifr_name, ifname, IFNAMSIZ-1);
ifr.ifr_name[IFNAMSIZ-1] = '\0';
if(ioctl(s, SIOCGIFNETMASK, &ifr, &ifrlen) < 0)
{
syslog(LOG_ERR, "ioctl(s, SIOCGIFNETMASK, ...): %m");