summaryrefslogtreecommitdiff
path: root/thirdparty/miniupnpc
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2021-03-15 14:38:13 +0100
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2021-03-15 17:33:26 +0100
commit163fc125cda09289feb6342215440358ed2163b6 (patch)
tree4dbd44f65a0892f6108832abe1074d5033050fd7 /thirdparty/miniupnpc
parent6eef187a81cbdd3cd314776de372e753f79f9831 (diff)
[Net] Fix miniupnpc when no interface is specified
This is a tricky one, it used to work, but it was wrong, because in such a scenario instead of passing NULL as required by the API, it would pass a buffer containing the `\0` terminator. This stopped working on a specific miniupnpc version, when they fixed some network endianess issue on Windows, to which we made a workaround, which in turn would probably result in failures when the interface is specified. This commit address the issue properly, by checking the specified interface string size, and correctly passing NULL instead of the empty string when necessary. Also reverts the commit that introduced the bogus workaround: e85330231c729a88d5a478de2bbe4a61e5edeae3 One of those PR when the explaination is much longer then code changes :).
Diffstat (limited to 'thirdparty/miniupnpc')
-rw-r--r--thirdparty/miniupnpc/miniupnpc/minissdpc.c4
-rw-r--r--thirdparty/miniupnpc/windows_fix.diff16
2 files changed, 4 insertions, 16 deletions
diff --git a/thirdparty/miniupnpc/miniupnpc/minissdpc.c b/thirdparty/miniupnpc/miniupnpc/minissdpc.c
index 36244dedec..a3b1283da5 100644
--- a/thirdparty/miniupnpc/miniupnpc/minissdpc.c
+++ b/thirdparty/miniupnpc/miniupnpc/minissdpc.c
@@ -683,7 +683,11 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
#endif
} else {
struct in_addr mc_if;
+#if defined(_WIN32) && (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
+ InetPtonA(AF_INET, multicastif, &mc_if);
+#else
mc_if.s_addr = inet_addr(multicastif); /* ex: 192.168.x.x */
+#endif
if(mc_if.s_addr != INADDR_NONE)
{
((struct sockaddr_in *)&sockudp_r)->sin_addr.s_addr = mc_if.s_addr;
diff --git a/thirdparty/miniupnpc/windows_fix.diff b/thirdparty/miniupnpc/windows_fix.diff
deleted file mode 100644
index 460b596888..0000000000
--- a/thirdparty/miniupnpc/windows_fix.diff
+++ /dev/null
@@ -1,16 +0,0 @@
-diff --git a/thirdparty/miniupnpc/miniupnpc/minissdpc.c b/thirdparty/miniupnpc/miniupnpc/minissdpc.c
-index 29f8110155..ea9af02e1f 100644
---- a/thirdparty/miniupnpc/miniupnpc/minissdpc.c
-+++ b/thirdparty/miniupnpc/miniupnpc/minissdpc.c
-@@ -683,11 +683,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
- #endif
- } else {
- struct in_addr mc_if;
--#if defined(_WIN32) && (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
-- InetPtonA(AF_INET, multicastif, &mc_if);
--#else
- mc_if.s_addr = inet_addr(multicastif); /* ex: 192.168.x.x */
--#endif
- if(mc_if.s_addr != INADDR_NONE)
- {
- ((struct sockaddr_in *)&sockudp_r)->sin_addr.s_addr = mc_if.s_addr;