miniupnpd: Allow wildcard (empty string) remote host for AddPinhole()

This commit is contained in:
Thomas Bernard 2015-02-10 16:04:10 +01:00
parent 5df35db6ab
commit 6e5d8ce954
3 changed files with 9 additions and 6 deletions

View File

@ -1,4 +1,7 @@
$Id: Changelog.txt,v 1.394 2014/12/10 09:33:24 nanard Exp $
$Id: Changelog.txt,v 1.395 2015/02/10 15:01:02 nanard Exp $
2015/02/10:
IP wildcard for AddPinhole() is empty string
2014/12/10:
Checking Host: HTTP request header to prevent DNS rebinding attack

View File

@ -1,4 +1,4 @@
/* $Id: iptpinhole.c,v 1.13 2015/02/08 09:44:20 nanard Exp $ */
/* $Id: iptpinhole.c,v 1.14 2015/02/10 15:01:03 nanard Exp $ */
/* MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* (c) 2012-2015 Thomas Bernard
@ -217,7 +217,7 @@ int add_pinhole(const char * ifname,
if(ifname)
strncpy(e->ipv6.iniface, ifname, IFNAMSIZ);
if(rem_host) {
if(rem_host && (rem_host[0] != '\0')) {
inet_pton(AF_INET6, rem_host, &e->ipv6.src);
memset(&e->ipv6.smsk, 0xff, sizeof(e->ipv6.smsk));
}
@ -350,7 +350,7 @@ get_pinhole_info(unsigned short uid,
p = get_pinhole(uid);
if(!p)
return -2; /* Not found */
if(rem_host) {
if(rem_host && (rem_host[0] != '\0')) {
if(inet_ntop(AF_INET6, &p->saddr, rem_host, rem_hostlen) == NULL)
return -1;
}

View File

@ -1,4 +1,4 @@
/* $Id: upnpsoap.c,v 1.134 2015/02/08 09:17:14 nanard Exp $ */
/* $Id: upnpsoap.c,v 1.135 2015/02/10 15:01:24 nanard Exp $ */
/* MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* (c) 2006-2015 Thomas Bernard
@ -1477,7 +1477,7 @@ AddPinhole(struct upnphttp * h, const char * action)
}
/* I guess it is useless to convert int_ip to literal ipv6 address */
/* rem_host should be converted to literal ipv6 : */
if(rem_host)
if(rem_host && (rem_host[0] != '\0'))
{
struct addrinfo *ai, *p;
struct addrinfo hints;