From ca9b8217b4d382a0a9084f089c17d78caebe2a19 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Mon, 21 Apr 2014 19:32:09 +0200 Subject: [PATCH] miniupnpd/pcpserver.c: Fix CheckExternalAddress() for working with 0 IPv4 mapped address fixes #69 --- miniupnpd/pcpserver.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/miniupnpd/pcpserver.c b/miniupnpd/pcpserver.c index 853e055..2e671a3 100644 --- a/miniupnpd/pcpserver.c +++ b/miniupnpd/pcpserver.c @@ -582,10 +582,12 @@ static int CheckExternalAddress(pcp_info_t* pcp_msg_info) } } - if (pcp_msg_info->ext_ip == NULL || IN6_IS_ADDR_UNSPECIFIED(pcp_msg_info->ext_ip)) { - + if (pcp_msg_info->ext_ip == NULL || + IN6_IS_ADDR_UNSPECIFIED(pcp_msg_info->ext_ip) || + (IN6_IS_ADDR_V4MAPPED(pcp_msg_info->ext_ip) + && ((uint32_t *)pcp_msg_info->ext_ip->s6_addr)[3] == INADDR_ANY)) { + /* no suggested external address : use real external address */ pcp_msg_info->ext_ip = &external_addr; - return 0; }