[Openvpn-devel] [M] Change in openvpn[master]: Add new unit test module test_socket

2025-08-28 Thread flichtenheld (Code Review)
Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

http://gerrit.openvpn.net/c/openvpn/+/1160?usp=email

to review the following change.


Change subject: Add new unit test module test_socket
..

Add new unit test module test_socket

With a first UT that tests add_in6_addr() (and
print_in6_addr implicitly).

Change-Id: If546f64a4554b292623bfcfe9ee53bac17dfa803
Signed-off-by: Frank Lichtenheld 
---
M CMakeLists.txt
M tests/unit_tests/openvpn/Makefile.am
M tests/unit_tests/openvpn/mock_management.c
A tests/unit_tests/openvpn/test_socket.c
4 files changed, 155 insertions(+), 10 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/60/1160/1

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 45044af..6ca08fb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -653,6 +653,7 @@
 "test_packet_id"
 "test_pkt"
 "test_provider"
+"test_socket"
 "test_ssl"
 "test_user_pass"
 "test_push_update_msg"
@@ -849,6 +850,15 @@
 src/openvpn/base64.c
 )

+target_sources(test_socket PRIVATE
+tests/unit_tests/openvpn/mock_get_random.c
+tests/unit_tests/openvpn/mock_management.c
+tests/unit_tests/openvpn/mock_win32_execve.c
+src/openvpn/env_set.c
+src/openvpn/run_command.c
+src/openvpn/socket_util.c
+)
+
 target_sources(test_user_pass PRIVATE
 tests/unit_tests/openvpn/mock_get_random.c
 tests/unit_tests/openvpn/mock_win32_execve.c
diff --git a/tests/unit_tests/openvpn/Makefile.am 
b/tests/unit_tests/openvpn/Makefile.am
index b24e03c..07d3ee9 100644
--- a/tests/unit_tests/openvpn/Makefile.am
+++ b/tests/unit_tests/openvpn/Makefile.am
@@ -4,23 +4,17 @@
 
 AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING) Unit-Tests'

-test_binaries=
+test_binaries = crypto_testdriver packet_id_testdriver auth_token_testdriver \
+   ncp_testdriver misc_testdriver pkt_testdriver ssl_testdriver \
+   user_pass_testdriver push_update_msg_testdriver provider_testdriver 
socket_testdriver

 if HAVE_LD_WRAP_SUPPORT
 test_binaries += argv_testdriver buffer_testdriver
-endif
-
-test_binaries += crypto_testdriver packet_id_testdriver auth_token_testdriver 
ncp_testdriver misc_testdriver \
-   pkt_testdriver ssl_testdriver user_pass_testdriver 
push_update_msg_testdriver
-
-if HAVE_LD_WRAP_SUPPORT
 if !WIN32
 test_binaries += tls_crypt_testdriver
 endif
 endif

-test_binaries += provider_testdriver
-
 if WIN32
 test_binaries += cryptoapi_testdriver
 LDADD = -lws2_32
@@ -343,4 +337,22 @@
$(top_srcdir)/src/openvpn/platform.c \
$(top_srcdir)/src/openvpn/push_util.c \
$(top_srcdir)/src/openvpn/options_util.c \
-   $(top_srcdir)/src/openvpn/otime.c
\ No newline at end of file
+   $(top_srcdir)/src/openvpn/otime.c
+
+socket_testdriver_CFLAGS  = \
+   -I$(top_srcdir)/include -I$(top_srcdir)/src/compat 
-I$(top_srcdir)/src/openvpn \
+   -DSOURCEDIR=\"$(top_srcdir)\" @TEST_CFLAGS@
+
+socket_testdriver_LDFLAGS = @TEST_LDFLAGS@
+
+socket_testdriver_SOURCES = test_socket.c \
+   mock_msg.c test_common.h  \
+   mock_get_random.c \
+   mock_management.c \
+   $(top_srcdir)/src/openvpn/buffer.c \
+   $(top_srcdir)/src/openvpn/win32-util.c \
+   $(top_srcdir)/src/openvpn/platform.c \
+   $(top_srcdir)/src/openvpn/env_set.c \
+   $(top_srcdir)/src/openvpn/run_command.c \
+   $(top_srcdir)/src/openvpn/socket_util.c
+
diff --git a/tests/unit_tests/openvpn/mock_management.c 
b/tests/unit_tests/openvpn/mock_management.c
index b24e4c4..ea470ca 100644
--- a/tests/unit_tests/openvpn/mock_management.c
+++ b/tests/unit_tests/openvpn/mock_management.c
@@ -46,4 +46,19 @@
 {
 return NULL;
 }
+
+void
+management_set_state(struct management *man, const int state, const char 
*detail,
+ const in_addr_t *tun_local_ip, const struct in6_addr 
*tun_local_ip6,
+ const struct openvpn_sockaddr *local_addr,
+ const struct openvpn_sockaddr *remote_addr)
+{
+}
+
+void
+management_sleep(const int n)
+{
+}
+
+
 #endif
diff --git a/tests/unit_tests/openvpn/test_socket.c 
b/tests/unit_tests/openvpn/test_socket.c
new file mode 100644
index 000..b30fce8
--- /dev/null
+++ b/tests/unit_tests/openvpn/test_socket.c
@@ -0,0 +1,108 @@
+/*
+ *  OpenVPN -- An application to securely tunnel IP networks
+ * over a single UDP port, with support for SSL/TLS-based
+ * session authentication and key exchange,
+ * packet encryption, packet authentication, and
+ * packet compression.
+ *
+ *  Copyright (C) 2021-2025 Arne Schwabe 
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2
+ *  as published by the Free Software

[Openvpn-devel] [XS] Change in openvpn[master]: socket_util: Clean up conversion warnings in add_in6_addr

2025-08-28 Thread flichtenheld (Code Review)
Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

http://gerrit.openvpn.net/c/openvpn/+/1161?usp=email

to review the following change.


Change subject: socket_util: Clean up conversion warnings in add_in6_addr
..

socket_util: Clean up conversion warnings in add_in6_addr

Change-Id: Id3b8719ee6b457ce2d85156b39e0cea771a97e74
Signed-off-by: Frank Lichtenheld 
---
M src/openvpn/socket_util.c
1 file changed, 3 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/61/1161/1

diff --git a/src/openvpn/socket_util.c b/src/openvpn/socket_util.c
index 13f8c32..9b7312d 100644
--- a/src/openvpn/socket_util.c
+++ b/src/openvpn/socket_util.c
@@ -241,14 +241,12 @@
 struct in6_addr
 add_in6_addr(struct in6_addr base, uint32_t add)
 {
-int i;
-
-for (i = 15; i >= 0 && add > 0; i--)
+for (int i = 15; i >= 0 && add > 0; i--)
 {
-register int carry;
+register uint32_t carry;
 register uint32_t h;

-h = (unsigned char)base.s6_addr[i];
+h = base.s6_addr[i];
 base.s6_addr[i] = (h + add) & UINT8_MAX;

 /* using explicit carry for the 8-bit additions will catch

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1161?usp=email
To unsubscribe, or for help writing mail filters, visit 
http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id3b8719ee6b457ce2d85156b39e0cea771a97e74
Gerrit-Change-Number: 1161
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld 
Gerrit-Reviewer: plaisthos 
Gerrit-CC: openvpn-devel 
Gerrit-Attention: plaisthos 
Gerrit-MessageType: newchange
___
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel


[Openvpn-devel] [S] Change in openvpn[master]: events: Make sure rwflags are treated as unsigned

2025-08-28 Thread flichtenheld (Code Review)
Attention is currently required from: plaisthos.

flichtenheld has posted comments on this change. ( 
http://gerrit.openvpn.net/c/openvpn/+/1107?usp=email )

Change subject: events: Make sure rwflags are treated as unsigned
..


Patch Set 9:

This change is ready for review.


--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1107?usp=email
To unsubscribe, or for help writing mail filters, visit 
http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I0272b709b907545de05bfded03a649b259ce5af6
Gerrit-Change-Number: 1107
Gerrit-PatchSet: 9
Gerrit-Owner: flichtenheld 
Gerrit-Reviewer: plaisthos 
Gerrit-CC: openvpn-devel 
Gerrit-Attention: plaisthos 
Gerrit-Comment-Date: Thu, 28 Aug 2025 12:50:02 +
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
___
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel