0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 04:02:15 +02:00
Commit Graph

4118 Commits

Author SHA1 Message Date
David Sommerseth
01a37cea97
Merge OpenVPN 3 Core Library release v3.8.3 to master
Signed-off-by: David Sommerseth <davids@openvpn.net>
2023-11-08 22:04:21 +01:00
Frank Lichtenheld
2413ad0b53
OpenSSLPKI::x509_get_serial: Handle NULL result from BN_bn2dec
The BN_bn2dec() can return NULL if the input is not parseable.
This would cause the conversion of char* to std::string to throw
an exception. Instead check the result and return an empty string
on errors.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-11-08 21:27:50 +01:00
Charlie Vigue
e2f3f7509a
numeric_util: Add missing cstdint include
Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com>
2023-11-08 21:23:31 +01:00
Frank Lichtenheld
f00c816a0f
cryptodc: remove stray ';'
This causes only warnings with -Wpedantic, which we don't
intend to use. But doesn't hurt to fix anyway.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-11-08 21:10:22 +01:00
Frank Lichtenheld
9b8797fe5e
CMake: Refine CXX_STANDARD setting
- Set CXX_STANDARD_REQUIRED ON so that we error out early
  if CMake thinks that the compiler does not support the
  used standard.
- Set CXX_EXTENSIONS OFF so that we get less compiler
  specific behavior.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-11-08 21:10:21 +01:00
Frank Lichtenheld
268bf42b9e
CMake: accept all NEW policies in released CMake versions
Using the <max> argument to cmake_minimum_required will
set all policies up to <max> to NEW. We might need to
fix some issues arising from that, but this means that
modern CMake can already behave like it wants even with
leaving <min> so that we can support old distros (currently
Debian 10).

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-11-08 21:10:20 +01:00
Frank Lichtenheld
72275db1d5
client: Switch to UseSWIG instead of manual custom command
On modern CMake this gets us swig dependency management,
which should reduce problems for incremental builds.
Also it is just cleaner.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-11-08 21:10:19 +01:00
Frank Lichtenheld
cb06f9e330
SplitLines/UserPass: Review fixes
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-11-08 21:05:06 +01:00
Frank Lichtenheld
1cf9556fe0
SplitLines: Add doxygen documentation
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-11-08 21:05:06 +01:00
Frank Lichtenheld
59a1d2398e
test_splitlines: New UT for SplitLines
Also enable UserPass UT that now passes with new
SplitLines.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-11-08 21:05:05 +01:00
Frank Lichtenheld
4620b1f8cd
SplitLines: throw on error
Except in the next() interface which allows for more
fine-grained error control.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-11-08 21:05:04 +01:00
Frank Lichtenheld
34c06c2f7a
UserPass: add doxygen documentation
Based on the understanding from the unittest.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-11-08 21:05:03 +01:00
Frank Lichtenheld
3eaac582d0
HTTPProxyTransport: Simplify parsing of http-proxy-user-pass
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-11-08 21:05:02 +01:00
Frank Lichtenheld
079fb4dd4d
UserPass: Add unittest
Fixed one issue while at it, with parse() not clearing
the username and password arguments.

The general issue that overflow doesn't throw is reflected in
a disabled test. This will need to be fixed in SplitLines,
probably.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-11-08 21:05:01 +01:00
Frank Lichtenheld
185182e1be
UserPass: rename one overload of parse to parse_file
This really has very different implications than the
others overloads. So make it distinct.

I would also rename the others to parse_opt, but feel
that causes too much churn in the code. parse_file has
only one use in our own code base.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-11-08 21:04:41 +01:00
David Sommerseth
7b145649c7
Release: OpenVPN 3 Core Library, version 3.8.3
Signed-off-by: David Sommerseth <davids@openvpn.net>
2023-11-08 12:59:24 +01:00
Lev Stipakov
97b3c0a594 Add route tables manipulation functionality
This adds two routines:

  AWS::Route::create_route_table

This creates route table in given VPC and
assigns "Name" tag to it with provided value.

  AWS::Route::get_route_table_by_name

This searches for route table with given "Name"
tag and either returns route table id or empty string
if route table doesn't exist.

These routines are used by Linux client AWS addon.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2023-10-26 12:12:58 +00:00
Arne Schwabe
384c749754
Add ifconfig, topology and route-gateway to push only options
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-10-25 22:35:48 +02:00
Arne Schwabe
66da32a859
Add block-outside-dns and tun-mtu-extra to ignore and warn list
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-10-25 22:35:47 +02:00
Arne Schwabe
89d382853e
Allow key-method 2 in OpenVPN3 client configs
Also this is a very rare option to be used today as it was for compatibility
with OpenVPN 1.x we should still not error out when it is present.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-10-25 22:35:46 +02:00
Arne Schwabe
0be01b8859
Do not warn twice about options in settings_feature_not_implemented_warn
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-10-25 22:35:45 +02:00
Arne Schwabe
bf5df01ac8
Add no-iv to the removed options that we cannot support anymore
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-10-25 22:35:44 +02:00
Arne Schwabe
153c80cfef
Add route-delay to ignored but warned options
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-10-25 22:35:43 +02:00
Arne Schwabe
181dafdb0d
Add unsupported option name in error message
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-10-25 22:35:43 +02:00
Arne Schwabe
11ec627a93
Allow ovpn::string::join to work also with other contains than std::vector
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-10-25 22:35:42 +02:00
Mark Deric
ef74a5b059 Improve psid cookie unit tests [OVPN3-1069]
-- Instantiate the PsidCookieImpl and spot check it's correctness
-- Check for client replies within and outside of the allowable time
   window

Signed-off-by: Mark Deric <jmark@openvpn.net>
2023-10-25 09:10:40 -07:00
Frank Lichtenheld
8713c7463e SITNL: Fix conversion warning related to route table id
For some reason the enum is much bigger than the field
in the API.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-10-24 15:29:31 +02:00
Frank Lichtenheld
6e7a98b5f4 CMake: Add USE_WCONVERSION option
Makes it easier to test with -Wconversion, e.g. in Jenkins.

For now disable -Wsign-conversion. That is the default in g++,
but not clang++. Once we have fixed all -Wsign-conversion
warnings, we can enable it for both.

For now disable -Wenum-enum-conversion. Only present in clang++.
Not clear whether cleaning those up will be worth the effort.

Disable -ferror-limit in clang++. This ensures that it always
displays all errors.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-10-24 15:29:31 +02:00
Mark Deric
3296f369f4 Fix Wconversion issues; improve comments
Conversion fixes:
-- use the protocol op field as a byte, not an int

-- fix the valid time hmac component calculation to avoid implicit
   64-to-32 narrowing.

Signed-off-by: Mark Deric <jmark@openvpn.net>
2023-10-22 11:51:10 -07:00
Mark Deric
50293847c4 Fix session_id_time calculation bug
The intent of the offset argument to the calculate_session_id_hmac()
function was to allow the server to accept hmac values calculated for
the previous time interval even as the server's clock moved into a new
time interval.

The bug was that the implementation checked for a match with the
server's current time interval and its _future_ time interval, and not
it's immediate past time interval.

This bug was pointed out during code review by Frank Lichtenheld.  The
code review subject was numeric conversions, in this case signed vs
unsigned. This author changed the offset to unsigned, arguing that the
code would never need to check the client hmac cookie based on both
sides of the server's current time.  The check only needed to be in
one direction, hence unsigned was the solution to the conversion
warning.  That was when Frank pointed out that implementation with the
"+ offset" snippet checked to see if the client provided a psid from
the future time interval and what was needed was to check for the past
interval, i.e., "- offset".

Hence, the change implements the unsigned offset, change add to
subtract from the time range computed for the server's currrent time
window.

Signed-off-by: Mark Deric <jmark@openvpn.net>
2023-10-21 17:02:38 -07:00
Arne Schwabe
34a1faf162 Fix logic of INFO_PRE and INFO substring replacment swapped
The refactoring introduced a logic error were the two options are
swapped.
2023-10-12 18:18:48 +02:00
Mark Deric
22af472e8a
Improve names
-- disambiguate new_obj(): new_man_obj(), new_tun_obj
-- remove obfuscatory typedef <class> Base; use <class>
-- in servproto.hpp typedef ProtoContext::ProtoConfig to ProtoConfig
   since Arne's already disambiguated Config
-- disambiguate Link<>: TCPLink<>, UDPLink<>

Added TODO comment on unneeded version of control_net_recv()

Signed-off-by: Mark Deric <jmark@openvpn.net>
2023-10-11 18:49:23 +02:00
Lev Stipakov
7df2a8530b Win: workaround for transient 0.0.0.0/0
When setting IP address with "gateway" option,
Windows by some reasons creates 0.0.0.0/0 route
which we later remove. However for a few seconds
while this route exists it might interfer with routing.

To work around that, we initially set tun interface metric to
very high, which makes Windows create a rougue route with
high metric. After a few seconds we delete that route and
set metric to a lowest value.

Fixes https://github.com/OpenVPN/openvpn3/issues/281

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2023-10-11 18:23:14 +03:00
Frank Lichtenheld
542457f986 test_clamp_typerange: avoid -Wconversion warning
Make sure the lambda return types are correct.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-10-11 12:28:55 +02:00
Frank Lichtenheld
227a8e7a65 test_proto: avoid -Wconversion warning
Instead of magic constant say what we want to say.
So that randrange also produces the correct output
type.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-10-11 12:28:55 +02:00
Frank Lichtenheld
73624b8331 TunBuilderCapture: avoid -Wconversion warning for prefix_length
For some reason RouteBase uses unsigned char for prefix_length
while all other code uses int or unsigned int. For now just
cast it, prefix_length should be <= 128 anyway.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-10-11 12:28:55 +02:00
Frank Lichtenheld
40d987f335 Avoid some -Wconversion warnings by changing parameter types
These functions can safely handle bigger types, so
avoid needless downcasts.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-10-11 12:28:55 +02:00
Mark Deric
989dd7ead5 Port the psid cookie defense from ovpn2
The psid cookie defense is designed to thwart resource exhaustion and
amplification attacks wherein a malicious client sends the server a
flood of CONTROL_HARD_RESET_CLIENT_V2 packets with spooofed source
addresses.  This patch allows the server to defer client tracking
state creation until the client responds to the server's
CONTROL_HARD_RESET_SERVER_V2 message.

Signed-off-by: Mark Deric <jmark@openvpn.net>
2023-10-03 12:42:29 -07:00
Frank Lichtenheld
f9c878b90b
xkey_helper: fix indentation of openvpn_msg_xkey_compat
This formatting is wrong even compared to the rest of
the file.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-09-28 11:33:49 +02:00
Frank Lichtenheld
d3355929ad
xkey_helper: Fix some conversion warnings
Weird mix of size_t and int.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-09-28 11:33:48 +02:00
Frank Lichtenheld
cf4fa0b3d6
MSVC: raise warning level for MSVC from /W2 to /W3
Now that all the warnings for /W3 are fixed, we can
use the default level again.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-09-28 11:33:47 +02:00
Frank Lichtenheld
2e10d21fa2
WriteFile takes DWORD, not size_t
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-09-28 11:33:46 +02:00
Frank Lichtenheld
a52371a267
Fix some more size_t->int conversions in OpenSSL support
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-09-28 11:33:45 +02:00
Frank Lichtenheld
7cd7b6619e
Fix misc wrong types
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-09-28 11:33:44 +02:00
Frank Lichtenheld
8a926bda94
dhcp_capture: Fix some conversion warnings
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-09-28 11:33:43 +02:00
Frank Lichtenheld
cdd58b62d1
Windows: Fix conversion warnings in Registry code
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-09-28 11:33:42 +02:00
Frank Lichtenheld
ced2eef9a1
wintun: Fix some ULONG vs size_t conversion warnings
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-09-28 11:33:42 +02:00
Frank Lichtenheld
8f7fdd10ff
Use openvpn_io::detail::socket_type instead of "int"
On Linux those might be identical, but not on Windows.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-09-28 11:33:41 +02:00
Frank Lichtenheld
cc5e61e81b
httpcommon.hpp: Add missing cast from CONTENT_LENGTH_TYPE to size_t
With the std::max we do make sure it is > 0, so this
should be safe.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-09-28 11:33:40 +02:00
Frank Lichtenheld
97924d6c92
Use uint64_t for hash values
They are uint64_t. Usually size_t is a uint64_t as
well, but not always (e.g. Win32).

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-09-28 11:33:39 +02:00