Skip to content

Commit 9f76e45

Browse files
committed
Drop support of insecure miniUPnPc versions
The minimum supported miniUPnPc API version is set to 10.
1 parent 8ec7121 commit 9f76e45

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ jobs:
139139
env: >-
140140
HOST=x86_64-unknown-linux-gnu
141141
DOCKER_NAME_TAG=ubuntu:14.04
142-
PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools libicu-dev libpng-dev libssl-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.1++-dev libminiupnpc-dev libzmq3-dev libprotobuf-dev protobuf-compiler libqrencode-dev"
142+
PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools libicu-dev libpng-dev libssl-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.1++-dev libzmq3-dev libprotobuf-dev protobuf-compiler libqrencode-dev"
143143
NO_DEPENDS=1
144144
RUN_FUNCTIONAL_TESTS=false
145145
GOAL="install"

src/net.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
#include <miniupnpc/miniwget.h>
3737
#include <miniupnpc/upnpcommands.h>
3838
#include <miniupnpc/upnperrors.h>
39+
// The minimum supported miniUPnPc API version is set to 10. This keeps compatibility
40+
// with Ubuntu 16.04 LTS and Debian 8 libminiupnpc-dev packages.
41+
static_assert(MINIUPNPC_API_VERSION >= 10, "miniUPnPc API version >= 10 assumed");
3942
#endif
4043

4144
#include <unordered_map>
@@ -1403,16 +1406,10 @@ static void ThreadMapPort()
14031406
struct UPNPDev * devlist = nullptr;
14041407
char lanaddr[64];
14051408

1406-
#ifndef UPNPDISCOVER_SUCCESS
1407-
/* miniupnpc 1.5 */
1408-
devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0);
1409-
#elif MINIUPNPC_API_VERSION < 14
1410-
/* miniupnpc 1.6 */
14111409
int error = 0;
1410+
#if MINIUPNPC_API_VERSION < 14
14121411
devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, &error);
14131412
#else
1414-
/* miniupnpc 1.9.20150730 */
1415-
int error = 0;
14161413
devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, 2, &error);
14171414
#endif
14181415

@@ -1446,15 +1443,8 @@ static void ThreadMapPort()
14461443
std::string strDesc = "Bitcoin " + FormatFullVersion();
14471444

14481445
do {
1449-
#ifndef UPNPDISCOVER_SUCCESS
1450-
/* miniupnpc 1.5 */
1451-
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
1452-
port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", 0);
1453-
#else
1454-
/* miniupnpc 1.6 */
14551446
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
14561447
port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", 0, "0");
1457-
#endif
14581448

14591449
if(r!=UPNPCOMMAND_SUCCESS)
14601450
LogPrintf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n",

0 commit comments

Comments
 (0)