From 333c28a5027e323194e289b48bc971d903f517b5 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Sat, 27 Apr 2013 17:51:53 +0200 Subject: [PATCH] miniupnpd/getifaddr.c: Uses ifr_addr if ifr_netmask is not defined in struct ifreq --- miniupnpd/Changelog.txt | 5 ++++- miniupnpd/getifaddr.c | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/miniupnpd/Changelog.txt b/miniupnpd/Changelog.txt index f587e61..55ec576 100644 --- a/miniupnpd/Changelog.txt +++ b/miniupnpd/Changelog.txt @@ -1,4 +1,7 @@ -$Id: Changelog.txt,v 1.335 2013/04/26 15:17:09 nanard Exp $ +$Id: Changelog.txt,v 1.336 2013/04/27 15:40:09 nanard Exp $ + +2013/04/27: + Uses ifr_addr if ifr_netmask is not defined in struct ifreq 2013/04/26: Correctly handle truncated snprintf() in SSDP code diff --git a/miniupnpd/getifaddr.c b/miniupnpd/getifaddr.c index 2090d55..8752e2c 100644 --- a/miniupnpd/getifaddr.c +++ b/miniupnpd/getifaddr.c @@ -1,4 +1,4 @@ -/* $Id: getifaddr.c,v 1.16 2013/03/23 10:46:54 nanard Exp $ */ +/* $Id: getifaddr.c,v 1.17 2013/04/27 15:40:09 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * (c) 2006-2013 Thomas Bernard @@ -70,7 +70,11 @@ getifaddr(const char * ifname, char * buf, int len, close(s); return -1; } +#ifdef ifr_netmask *mask = ((struct sockaddr_in *)&ifr.ifr_netmask)->sin_addr; +#else + *mask = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr; +#endif } close(s); #else /* ifndef USE_GETIFADDRS */