mirror of
https://github.com/status-im/miniupnp.git
synced 2025-02-16 16:07:30 +00:00
DEfault to client address for AddPortMapping when <NewInternalClient> is empty
see #236
This commit is contained in:
parent
1c893933dc
commit
93845c5abe
@ -1,5 +1,9 @@
|
||||
$Id: Changelog.txt,v 1.430 2016/12/16 09:14:40 nanard Exp $
|
||||
|
||||
2017/03/13:
|
||||
default to client address for AddPortMapping when <NewInternalClient>
|
||||
is empty
|
||||
|
||||
2016/12/23:
|
||||
Fix UDA-1.2.10 Man header empty or invalid
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* $Id: upnpsoap.c,v 1.144 2016/02/12 12:35:03 nanard Exp $ */
|
||||
/* MiniUPnP project
|
||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
* (c) 2006-2016 Thomas Bernard
|
||||
* (c) 2006-2017 Thomas Bernard
|
||||
* This software is subject to the conditions detailed
|
||||
* in the LICENCE file provided within the distribution */
|
||||
|
||||
@ -388,12 +388,19 @@ AddPortMapping(struct upnphttp * h, const char * action, const char * ns)
|
||||
|
||||
ParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data);
|
||||
int_ip = GetValueFromNameValueList(&data, "NewInternalClient");
|
||||
if (!int_ip)
|
||||
if (int_ip) {
|
||||
/* trim */
|
||||
while(int_ip[0] == ' ')
|
||||
int_ip++;
|
||||
}
|
||||
#ifdef UPNP_STRICT
|
||||
if (!int_ip || int_ip[0] == '\0')
|
||||
{
|
||||
ClearNameValueList(&data);
|
||||
SoapError(h, 402, "Invalid Args");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* IGD 2 MUST support both wildcard and specific IP address values
|
||||
* for RemoteHost (only the wildcard value was REQUIRED in release 1.0) */
|
||||
@ -409,6 +416,16 @@ AddPortMapping(struct upnphttp * h, const char * action, const char * ns)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef UPNP_STRICT
|
||||
/* if <NewInternalClient> arg is empty, use client address
|
||||
* see https://github.com/miniupnp/miniupnp/issues/236 */
|
||||
if (!int_ip || int_ip[0] == '\0')
|
||||
{
|
||||
int_ip = h->clientaddr_str;
|
||||
memcpy(&result_ip, &(h->clientaddr), sizeof(struct in_addr));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
/* if ip not valid assume hostname and convert */
|
||||
if (inet_pton(AF_INET, int_ip, &result_ip) <= 0)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user