Skip to content

Commit 59cb722

Browse files
committed
Update configure to reject unsafe miniUPnPc API ver
Also fixes behavior when libminiupnpc is not installed.
1 parent ab21905 commit 59cb722

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

configure.ac

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,26 @@ if test x$use_upnp != xno; then
928928
[AC_CHECK_LIB([miniupnpc], [upnpDiscover], [MINIUPNPC_LIBS=-lminiupnpc], [have_miniupnpc=no])],
929929
[have_miniupnpc=no]
930930
)
931+
dnl The minimum supported miniUPnPc API version is set to 10. This keeps compatibility
932+
dnl with Ubuntu 16.04 LTS and Debian 8 libminiupnpc-dev packages.
933+
if test x$have_miniupnpc != xno; then
934+
AC_MSG_CHECKING([whether miniUPnPc API version is supported])
935+
AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
936+
@%:@include <miniupnpc/miniupnpc.h>
937+
]], [[
938+
#if MINIUPNPC_API_VERSION >= 10
939+
// Everything is okay
940+
#else
941+
# error miniUPnPc API version is too old
942+
#endif
943+
]])],[
944+
AC_MSG_RESULT(yes)
945+
],[
946+
AC_MSG_RESULT(no)
947+
AC_MSG_WARN([miniUPnPc API version < 10 is unsupported, disabling UPnP support.])
948+
have_miniupnpc=no
949+
])
950+
fi
931951
fi
932952

933953
BITCOIN_QT_INIT
@@ -1326,9 +1346,10 @@ dnl enable upnp support
13261346
AC_MSG_CHECKING([whether to build with support for UPnP])
13271347
if test x$have_miniupnpc = xno; then
13281348
if test x$use_upnp = xyes; then
1329-
AC_MSG_ERROR("UPnP requested but cannot be built. use --without-miniupnpc")
1349+
AC_MSG_ERROR("UPnP requested but cannot be built. Use --without-miniupnpc.")
13301350
fi
13311351
AC_MSG_RESULT(no)
1352+
use_upnp=no
13321353
else
13331354
if test x$use_upnp != xno; then
13341355
AC_MSG_RESULT(yes)

0 commit comments

Comments
 (0)