Commit Graph

2138 Commits

Author SHA1 Message Date
Pali Rohár 8cd542a809 Fix snprintf emulation for Windows
* Move it into separate win32_snprintf.h file to de-duplicate its
  implementation from all miniupnp source files.

* Do not use this emulation with mingw32 SDK when __NO_ISOCEXT is not
  defined as in this case mingw32 provides working snprintf function.

* Fix detection for mingw-w64 variants, when __NO_ISOCEXT is defined or
  when older version without UCRT is used.

* Add check if _scprintf function is available. In case it is not available
  just returns length of filled buffer to prevent buffer overflow.
2020-10-18 20:29:53 +02:00
Thomas Bernard 18a6ab0201
AddAnyPortMapping(): Only try allowed ports
build an array of all allowed ports.
should fix #465
2020-10-18 00:20:24 +02:00
Thomas Bernard 3a17dea056 pass rule type to the private arg of mnl_cb_run() callback
should fix #481
2020-10-17 23:20:29 +02:00
Thomas Bernard a3522723ae fix .gitignore 2020-10-17 22:55:12 +02:00
Thomas Bernard 2595275eb5 netfilter_nft: build testing 2020-10-17 22:52:34 +02:00
Thomas Bernard bd71e2e279
miniupnpc/addr_is_reserved.c: include sys/types.h 2020-10-17 22:13:32 +02:00
Thomas Bernard 138b4ff3aa
Fix for compiling with old windows SDK 2020-10-17 22:03:22 +02:00
Thomas Bernard 7a66f373fc inet_pton() instead of inet_addr() 2020-10-17 15:19:58 +02:00
Thomas Bernard 69fc376929 add addr_is_reserved.c/.h to MSVC project files
fixes #489
2020-10-17 15:15:59 +02:00
Thomas Bernard 63bf239a3e remove unused definitions
see #489
2020-10-17 14:56:58 +02:00
Thomas Bernard 062b562c37 ignore *.opendb 2020-10-17 14:49:43 +02:00
Thomas Bernard ad056c3629 update thanks list 2020-10-07 00:19:45 +02:00
Thomas Bernard 9ec4351829
Fix solaris build
fixes #490
2020-10-07 00:17:16 +02:00
Pali Rohár f5f693876d miniupnpc: By default skip invalid, disconnected and non-IGD devices
Allow to use such IGD devices by new -i option.
2020-10-05 22:30:30 +02:00
Thomas Bernard 11c479fb2a Merge remote-tracking branch 'pali/master' 2020-10-05 22:02:29 +02:00
Thomas Bernard c7cfe2c51a
fix compilation warning (WIN32) 2020-10-05 21:56:32 +02:00
Pali Rohár fc74c42864 miniupnpc: Fix name of miniupnpc import library in setupmingw32.py 2020-10-02 22:52:26 +02:00
Pali Rohár 7d5fdf0743 miniupnpc: Fix usage of Windows _snprintf() function
_snprintf() differs from snprintf() in:

* on overflow it returns -1 instead of required buffer size
* on overflow it does not fill nul byte
* does not accept NULL/0 as a buffer

Microsoft implemented snprintf() in Visual Studio 2015 as part of UCRT.

Mingw32 contains snprintf() implementation only when __USE_MINGW_ANSI_STDIO
is defined.

Mingw-w64 versions prior to 8.0.0. contain snprintf() implementation when
__USE_MINGW_ANSI_STDIO or _UCRT is defined. Since version 8.0.0 it is
always supported.

Mingw-w64 defines both __MINGW32__ and __MINGW64_VERSION_MAJOR macros.
Mingw32 defines only __MINGW32__.

_scprintf() just count number of bytes needed for formatting string, so it
is basically return value of snprintf().

This change updates miniupnpc code to use snprintf() when is provided by
compiler/runtime to avoid usage _snprintf().

And also this changes updates miniupnpc emulation of snprintf() by
_snprintf() and _scprintf() functions to avoid buffer overflows.

For inspiration full emulation of snprintf() by _snprintf() is available in
mingw-w64 stdio library:

https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-crt/stdio/snprintf.c
2020-10-02 22:32:36 +02:00
Thomas Bernard 992565201b fix testnftnlrdr.c 2020-09-29 01:00:29 +02:00
BERNARD Thomas 91ff44c9d2 netfilter_nft: fix test stuff 2020-09-29 00:43:55 +02:00
Thomas Bernard 11dec5b25c fix log 2020-09-29 00:17:58 +02:00
Thomas Bernard c1eb7c0069 update Changelog 2020-09-28 23:25:23 +02:00
Thomas Bernard 6358882f19 check string passed to atoi() 2020-09-28 23:24:54 +02:00
Thomas Bernard cce4407d9d check for malformed HTTP response 2020-09-28 23:23:17 +02:00
Thomas Bernard f9908a788b Move chain name variables to netfilter/* 2020-09-28 22:44:24 +02:00
Thomas Bernard 61d4aecb6e fix warning 2020-09-28 21:58:08 +02:00
Thomas Bernard 7db8ef0921 fix c9f6ddd 2020-09-28 21:57:50 +02:00
Thomas Bernard c9f6ddd102
miniupnpd/netfilter_nft: more logs in set_rdr_name()
see #481
2020-09-26 17:42:26 +02:00
Thomas Bernard 426f9a1835 fix warning 2020-09-24 10:38:05 +02:00
Thomas Bernard 2db013d891
use GetTickCount()/GetTickCount64() under windows
GetTickCount() when GetTickCount64() is not available
2020-09-24 10:19:09 +02:00
Thomas Bernard af1ea9f60b
miniupnpc: use clock_gettime() instead of gettimeofday() if possible 2020-09-24 10:19:08 +02:00
Thomas Bernard aa490867b3
prevent infinite loop in upnpDiscover()
fixes #488
2020-09-24 10:19:08 +02:00
Thomas Bernard a21a35e003 Merge branch 'pr-485' 2020-09-24 10:15:40 +02:00
Thomas Bernard 0c556655ea
Move addr_is_reserved() to a specific source file and test it 2020-09-24 09:57:25 +02:00
Thomas Bernard 2cb3589d59 Merge branch 'issue-464' 2020-09-02 00:01:56 +02:00
Pali Rohár 96aa863c78 Fix check for reserved IP addresses in miniupnpc
Check for 0.0.0.0, 192.168., 10. and 172. is not enough. Nowadays routers
behind NAT are getting IP address from shared CG-NAT space 100.64.0.0/10.

This patch adjust miniupnpc to check for all reserved IPv4 addresses.
2020-08-05 16:26:26 +02:00
Henrik Rydgård 7e229ddd63 Fix Windows UWP build. 2020-07-21 23:42:42 +02:00
Pali Rohár dbb821a7c9 getifaddr.c: Fix mask for RFC7534 Direct Delegation AS112 Service 2020-07-12 13:45:30 +02:00
Thomas Bernard d7b40010d5
nftnlrdr_misc.c: add log in case of send_batch() failure
useful for #481
2020-07-09 11:16:47 +02:00
Chen Minqiang b44e5e7a83 fix update_portmapping() missing target when update filter table 2020-06-27 11:31:08 +08:00
Thomas Bernard fca45a6773
update .travis.yml 2020-06-21 00:03:26 +02:00
Thomas Bernard 24df04fc1b update 2020-06-20 17:49:19 +02:00
Thomas Bernard 7a9452fca9
miniupnpd: make sure "runtime_vars" are initialized 2020-06-20 17:02:19 +02:00
Thomas Bernard 5bbcc0bb65
miniupnpd --help shows usage 2020-06-20 17:01:01 +02:00
Thomas Bernard 417b496617
miniupnpd: add -v/-vv command line argument to enable more logs
fixes #477
2020-06-20 17:00:10 +02:00
Thomas Bernard 686b41fc52
AddAnyPortMapping(): support wildcard in NewExternalPort
supported wildcard is either 0 or *
2020-06-20 16:38:14 +02:00
Thomas Bernard de71eef493
miniupnpd: AddAnyPortMapping() tries port above and below requested port
fixes #465
if the requested port is n, it will tries successively :
n, n+1, n-1, n+2, n-2, n+3, n-3, etc.
2020-06-20 16:38:14 +02:00
Thomas BERNARD 1e7fb305b6
Merge pull request #475 from miniupnp/issue-474
improve netfilter_nft code
2020-06-11 14:53:38 +02:00
Renato Botelho 1baa95277d Fix manpage installation on BSD
Respect MANPREFIX when it's set, when not, use PREFIX
2020-06-10 14:38:23 -03:00
Thomas Bernard 86b6aad797
ido not use depreacted nftnl_rule_set() and nftnl_chain_set()
now uses nftnl_rule_set_str() and nftnl_chain_set_str()
fixes #476
2020-06-10 11:55:42 +02:00