From 096478dce19731ffe6fbba61dfad2fea4b57b37e Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Tue, 14 Nov 2023 21:15:58 +0100 Subject: [PATCH] fix getifaddr() error case see #670 --- miniupnpd/getifaddr.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/miniupnpd/getifaddr.c b/miniupnpd/getifaddr.c index f7268ab..b6eaee1 100644 --- a/miniupnpd/getifaddr.c +++ b/miniupnpd/getifaddr.c @@ -2,7 +2,7 @@ /* vim: tabstop=4 shiftwidth=4 noexpandtab * MiniUPnP project * http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/ - * (c) 2006-2022 Thomas Bernard + * (c) 2006-2023 Thomas Bernard * This software is subject to the conditions detailed * in the LICENCE file provided within the distribution */ @@ -148,6 +148,12 @@ getifaddr(const char * ifname, char * buf, int len, if(addr) *addr = ((struct sockaddr_in *)candidate->ifa_addr)->sin_addr; if(mask) *mask = ((struct sockaddr_in *)candidate->ifa_netmask)->sin_addr; } + else + { + syslog(LOG_WARNING, "no AF_INET address found for %s", ifname); + freeifaddrs(ifap); + return -1; + } freeifaddrs(ifap); #endif return 0;