diff --git a/miniupnpd/Changelog.txt b/miniupnpd/Changelog.txt index 33e2031..96cfc6e 100644 --- a/miniupnpd/Changelog.txt +++ b/miniupnpd/Changelog.txt @@ -1,5 +1,8 @@ $Id: Changelog.txt,v 1.464 2020/05/10 17:57:56 nanard Exp $ +2020/06/05: + fix handling of ipv4 M-SEARCH received on ipv6 sockets + 2020/06/03: configure --disable-fork to disable going to background improve upnp_get_portmapping_number_of_entries() diff --git a/miniupnpd/minissdp.c b/miniupnpd/minissdp.c index 64257ca..f96f75f 100644 --- a/miniupnpd/minissdp.c +++ b/miniupnpd/minissdp.c @@ -1126,7 +1126,13 @@ ProcessSSDPData(int s, const char *bufr, int n, syslog(LOG_INFO, "SSDP M-SEARCH from %s ST: %.*s", sender_str, st_len, st); /* find in which sub network the client is */ +#ifdef ENABLE_IPV6 + if((sender->sa_family == AF_INET) || + (sender->sa_family == AF_INET6 && + IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)sender)->sin6_addr))) +#else if(sender->sa_family == AF_INET) +#endif { if (lan_addr == NULL) { @@ -1138,7 +1144,7 @@ ProcessSSDPData(int s, const char *bufr, int n, announced_host = lan_addr->str; } #ifdef ENABLE_IPV6 - else + else if(sender->sa_family == AF_INET6) { /* IPv6 address with brackets */ #ifdef UPNP_STRICT @@ -1178,6 +1184,13 @@ ProcessSSDPData(int s, const char *bufr, int n, #endif } #endif + else + { + syslog(LOG_ERR, + "Unknown address family %d for client %s", + sender->sa_family, sender_str); + return; + } /* Responds to request with a device as ST header */ for(i = 0; known_service_types[i].s; i++) {