Try to handle scope id in link local IPv6 URL under MS Windows
This commit is contained in:
parent
f9c6d4709e
commit
0aea9dc0fb
|
@ -3,6 +3,7 @@ miniUPnP client Changelog.
|
|||
|
||||
2012/08/11:
|
||||
Fix a memory link in UPNP_GetValidIGD()
|
||||
Try to handle scope id in link local IPv6 URL under MS Windows
|
||||
|
||||
2012/07/20:
|
||||
Disable HAS_IP_MREQN on DragonFly BSD
|
||||
|
|
|
@ -739,15 +739,24 @@ GetUPNPUrls(struct UPNPUrls * urls, struct IGDdatas * data,
|
|||
{
|
||||
char * p;
|
||||
int n1, n2, n3, n4;
|
||||
#ifdef IF_NAMESIZE
|
||||
char ifname[IF_NAMESIZE];
|
||||
#else
|
||||
char scope_str[8];
|
||||
#endif
|
||||
|
||||
n1 = strlen(data->urlbase);
|
||||
if(n1==0)
|
||||
n1 = strlen(descURL);
|
||||
if(scope_id != 0) {
|
||||
#ifdef IF_NAMESIZE
|
||||
if(if_indextoname(scope_id, ifname)) {
|
||||
n1 += 3 + strlen(ifname); /* 3 == strlen(%25) */
|
||||
}
|
||||
#else
|
||||
/* under windows, scope is numerical */
|
||||
snprintf(scope_str, sizeof(scope_str), "%u", scope_id);
|
||||
#endif
|
||||
}
|
||||
n1 += 2; /* 1 byte more for Null terminator, 1 byte for '/' if needed */
|
||||
n2 = n1; n3 = n1; n4 = n1;
|
||||
|
@ -778,9 +787,15 @@ GetUPNPUrls(struct UPNPUrls * urls, struct IGDdatas * data,
|
|||
p = strchr(urls->ipcondescURL, ']');
|
||||
if(p) {
|
||||
/* insert %25<scope> into URL */
|
||||
#ifdef IF_NAMESIZE
|
||||
memmove(p + 3 + strlen(ifname), p, strlen(p) + 1);
|
||||
memcpy(p, "%25", 3);
|
||||
memcpy(p + 3, ifname, strlen(ifname));
|
||||
#else
|
||||
memmove(p + 3 + strlen(scope_str), p, strlen(p) + 1);
|
||||
memcpy(p, "%25", 3);
|
||||
memcpy(p + 3, scope_str, strlen(scope_str));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: miniwget.c,v 1.57 2012/06/23 22:35:58 nanard Exp $ */
|
||||
/* $Id: miniwget.c,v 1.58 2012/08/11 05:52:49 nanard Exp $ */
|
||||
/* Project : miniupnp
|
||||
* Website : http://miniupnp.free.fr/
|
||||
* Author : Thomas Bernard
|
||||
|
@ -470,6 +470,20 @@ parseURL(const char * url,
|
|||
if(*scope_id == 0) {
|
||||
*scope_id = (unsigned int)strtoul(tmp, NULL, 10);
|
||||
}
|
||||
#else
|
||||
/* under windows, scope is numerical */
|
||||
char tmp[8];
|
||||
int l;
|
||||
scope++;
|
||||
/* "%25" is just '%' in URL encoding */
|
||||
if(scope[0] == '2' && scope[1] == '5')
|
||||
scope += 2; /* skip "25" */
|
||||
l = p2 - scope;
|
||||
if(l >= sizeof(tmp))
|
||||
l = sizeof(tmp) - 1;
|
||||
memcpy(tmp, scope, l);
|
||||
tmp[l] = '\0';
|
||||
*scope_id = (unsigned int)strtoul(tmp, NULL, 10);
|
||||
#endif
|
||||
}
|
||||
p3 = strchr(p1, '/');
|
||||
|
|
Loading…
Reference in New Issue