diff --git a/miniupnpc/Changelog.txt b/miniupnpc/Changelog.txt index 2616430..64e97f3 100644 --- a/miniupnpc/Changelog.txt +++ b/miniupnpc/Changelog.txt @@ -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 diff --git a/miniupnpc/miniupnpc.c b/miniupnpc/miniupnpc.c index fd96b0f..f576ff6 100644 --- a/miniupnpc/miniupnpc.c +++ b/miniupnpc/miniupnpc.c @@ -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 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 } } } diff --git a/miniupnpc/miniwget.c b/miniupnpc/miniwget.c index d60b8d8..31f3af0 100644 --- a/miniupnpc/miniwget.c +++ b/miniupnpc/miniwget.c @@ -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, '/');