From: "flichtenheld (Code Review)" Date: Wed, 1 Apr 2026 11:12:32 +0000 In-Reply-To: References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, gert@...1296... Message-ID: <22fe75d51dc2d7a71329bee9c337c3fe48dc42d2-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="X5drm9fmOWc="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: options: Change all users of positive_atoll to uint64_t List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --X5drm9fmOWc= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: cron2, flichtenheld, plaisthos. Hello cron2, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/1526?usp=3Demail to look at the new patch set (#9). The following approvals got outdated and were removed: Code-Review-1 by cron2 Change subject: options: Change all users of positive_atoll to uint64_t ...................................................................... options: Change all users of positive_atoll to uint64_t Generally this makes more sense for the usages. There is really no reason to make them signed just to have -1 as the default value. 0 works fine for that. Avoids some existing sign-compare warnings. Change-Id: I701452496bb47c58b9728b08104dd5cb7823a94f Signed-off-by: Frank Lichtenheld --- M src/openvpn/forward.c M src/openvpn/forward.h M src/openvpn/openvpn.h M src/openvpn/options.c M src/openvpn/options.h M src/openvpn/options_util.c M src/openvpn/options_util.h M src/openvpn/ssl.c M src/openvpn/ssl_common.h M tests/unit_tests/openvpn/test_misc.c 10 files changed, 23 insertions(+), 32 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/26/1526/9 diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 27cfd36..e3ba0ed 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -482,11 +482,11 @@ if (dco_enabled(&c->options) && dco_get_peer_stats(c, true) =3D=3D 0) { #ifdef TARGET_FREEBSD - int64_t tot_bytes =3D c->c2.dco_read_bytes + c->c2.dco_write_bytes; + counter_type tot_bytes =3D c->c2.dco_read_bytes + c->c2.dco_write_= bytes; #else - int64_t tot_bytes =3D c->c2.tun_read_bytes + c->c2.tun_write_bytes; + counter_type tot_bytes =3D c->c2.tun_read_bytes + c->c2.tun_write_= bytes; #endif - int64_t new_bytes =3D tot_bytes - c->c2.inactivity_bytes; + counter_type new_bytes =3D tot_bytes - c->c2.inactivity_bytes; if (new_bytes > c->options.inactivity_minimum_bytes) { diff --git a/src/openvpn/forward.h b/src/openvpn/forward.h index 0d3e492..bedad67 100644 --- a/src/openvpn/forward.h +++ b/src/openvpn/forward.h @@ -347,7 +347,7 @@ } static inline void -register_activity(struct context *c, const int64_t size) +register_activity(struct context *c, const uint64_t size) { if (c->options.inactivity_timeout) { diff --git a/src/openvpn/openvpn.h b/src/openvpn/openvpn.h index fa00822..864c160 100644 --- a/src/openvpn/openvpn.h +++ b/src/openvpn/openvpn.h @@ -285,7 +285,7 @@ /* --inactive */ struct event_timeout inactivity_interval; - int64_t inactivity_bytes; + counter_type inactivity_bytes; struct event_timeout session_interval; diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 713dcf4..0d32b23 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -864,9 +864,9 @@ o->replay_time =3D DEFAULT_TIME_BACKTRACK; o->key_direction =3D KEY_DIRECTION_BIDIRECTIONAL; o->tls_timeout =3D 2; - o->renegotiate_bytes =3D -1; + o->renegotiate_bytes =3D 0; o->renegotiate_seconds =3D 3600; - o->renegotiate_seconds_min =3D -1; + o->renegotiate_seconds_min =3D 0; o->handshake_window =3D 60; o->transition_window =3D 3600; o->tls_cert_profile =3D NULL; @@ -955,7 +955,7 @@ SHOW_PARM(var, o->var##_inline ? "[INLINE]" : (o->var ? o->var : "[UND= EF]"), "'%s'") #define SHOW_INT(var) SHOW_PARM(var, o->var, "%d") #define SHOW_UINT(var) SHOW_PARM(var, o->var, "%u") -#define SHOW_INT64(var) SHOW_PARM(var, o->var, "%" PRIi64) +#define SHOW_UINT64(var) SHOW_PARM(var, o->var, "%" PRIu64) #define SHOW_UNSIGNED(var) SHOW_PARM(var, o->var, "0x%08x") #define SHOW_BOOL(var) SHOW_PARM(var, (o->var ? "ENABLED" : "DISABLED"= ), "%s"); @@ -1715,7 +1715,7 @@ SHOW_INT(keepalive_timeout); SHOW_INT(inactivity_timeout); SHOW_INT(session_timeout); - SHOW_INT64(inactivity_minimum_bytes); + SHOW_UINT64(inactivity_minimum_bytes); SHOW_INT(ping_send_timeout); SHOW_INT(ping_rec_timeout); SHOW_INT(ping_rec_timeout_action); @@ -1892,8 +1892,8 @@ SHOW_INT(tls_timeout); - SHOW_INT64(renegotiate_bytes); - SHOW_INT64(renegotiate_packets); + SHOW_UINT64(renegotiate_bytes); + SHOW_UINT64(renegotiate_packets); SHOW_INT(renegotiate_seconds); SHOW_INT(handshake_window); diff --git a/src/openvpn/options.h b/src/openvpn/options.h index 422820c..02b1e98 100644 --- a/src/openvpn/options.h +++ b/src/openvpn/options.h @@ -341,7 +341,7 @@ int keepalive_timeout; int inactivity_timeout; /* --inactive */ - int64_t inactivity_minimum_bytes; + uint64_t inactivity_minimum_bytes; int session_timeout; /* Force-kill session after n seconds */ @@ -639,8 +639,8 @@ int tls_timeout; /* Data channel key renegotiation parameters */ - int64_t renegotiate_bytes; - int64_t renegotiate_packets; + uint64_t renegotiate_bytes; + uint64_t renegotiate_packets; int renegotiate_seconds; int renegotiate_seconds_min; diff --git a/src/openvpn/options_util.c b/src/openvpn/options_util.c index 47fe0bc..6ea0c7b 100644 --- a/src/openvpn/options_util.c +++ b/src/openvpn/options_util.c @@ -132,7 +132,7 @@ } bool -positive_atoll(const char *str, int64_t *value, const char *name, msglvl_t= msglevel) +positive_atoll(const char *str, uint64_t *value, const char *name, msglvl_= t msglevel) { char *endptr; long long ll =3D strtoll(str, &endptr, 10); @@ -143,7 +143,7 @@ return false; } - *value =3D (int64_t)ll; + *value =3D (uint64_t)ll; return true; } diff --git a/src/openvpn/options_util.h b/src/openvpn/options_util.h index 1d4ea9b..1b007fe 100644 --- a/src/openvpn/options_util.h +++ b/src/openvpn/options_util.h @@ -48,7 +48,7 @@ * * @return \c true if the integer has been parsed and stored in value, \c = false otherwise */ -bool positive_atoll(const char *str, int64_t *value, const char *name, msg= lvl_t msglevel); +bool positive_atoll(const char *str, uint64_t *value, const char *name, ms= glvl_t msglevel); /** * Converts a str to an integer if the string can be represented as an diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c index 576157d..cf8d644 100644 --- a/src/openvpn/ssl.c +++ b/src/openvpn/ssl.c @@ -103,11 +103,11 @@ * May *not* be NULL. */ static void -tls_limit_reneg_bytes(const char *ciphername, int64_t *reneg_bytes) +tls_limit_reneg_bytes(const char *ciphername, uint64_t *reneg_bytes) { if (cipher_kt_insecure(ciphername)) { - if (*reneg_bytes =3D=3D -1) /* Not user-specified */ + if (*reneg_bytes =3D=3D 0) /* Not user-specified */ { msg(M_WARN, "WARNING: cipher with small block size in use, " "reducing reneg-bytes to 64MB to mitigate SWEET32 = attacks."); @@ -2916,11 +2916,6 @@ return true; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif - /** * Determines if a renegotiation should be triggerred based on the various * factors that can trigger one @@ -2942,7 +2937,7 @@ } /* Packet limit */ - if (session->opt->renegotiate_packets && ks->n_packets >=3D session->o= pt->renegotiate_packets) + if (session->opt->renegotiate_packets > 0 && ks->n_packets >=3D sessio= n->opt->renegotiate_packets) { return true; } @@ -3000,10 +2995,6 @@ return false; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - /* * This is the primary routine for processing TLS stuff inside the * the main event loop. When this routine exits diff --git a/src/openvpn/ssl_common.h b/src/openvpn/ssl_common.h index 6f310a5..7b35ef3 100644 --- a/src/openvpn/ssl_common.h +++ b/src/openvpn/ssl_common.h @@ -342,8 +342,8 @@ int transition_window; int handshake_window; interval_t packet_timeout; - int64_t renegotiate_bytes; - int64_t renegotiate_packets; + uint64_t renegotiate_bytes; + uint64_t renegotiate_packets; /** limit for AEAD cipher when not running in epoch data key mode, * this is the sum of packets + blocks that are allowed to be used */ uint64_t aead_usage_limit; diff --git a/tests/unit_tests/openvpn/test_misc.c b/tests/unit_tests/openvp= n/test_misc.c index a9ae33f..19303a9 100644 --- a/tests/unit_tests/openvpn/test_misc.c +++ b/tests/unit_tests/openvpn/test_misc.c @@ -359,7 +359,7 @@ assert_true(atoi_constrained("-1194", ¶meter, "test", INT_MIN, INT= _MAX, msglevel)); assert_int_equal(parameter, -1194); - int64_t parameter64 =3D 0; + uint64_t parameter64 =3D 0; assert_true(positive_atoll("1234", ¶meter64, "test", msglevel)); assert_int_equal(parameter64, 1234); assert_true(positive_atoll("0", ¶meter64, "test", msglevel)); -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1526?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I701452496bb47c58b9728b08104dd5cb7823a94f Gerrit-Change-Number: 1526 Gerrit-PatchSet: 9 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: cron2 Gerrit-Attention: flichtenheld --X5drm9fmOWc= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: cron2, flichtenheld, plaisthos.

flichtenheld uploaded patch set #9 to this change.

<= p>View C= hange

The following approvals got outdated and were removed: Code-Review-1 by cron2

options: Change all users of positi=
ve_atoll to uint64_t

Generally this makes more sense for the usages.= There
is really no reason to make them signed just to have
-1 as the= default value. 0 works fine for that.

Avoids some existing sign-com= pare warnings.

Change-Id: I701452496bb47c58b9728b08104dd5cb7823a94f<= br>Signed-off-by: Frank Lichtenheld <frank@...2641...>
---
M sr= c/openvpn/forward.c
M src/openvpn/forward.h
M src/openvpn/openvpn.hM src/openvpn/options.c
M src/openvpn/options.h
M src/openvpn/optio= ns_util.c
M src/openvpn/options_util.h
M src/openvpn/ssl.c
M src/o= penvpn/ssl_common.h
M tests/unit_tests/openvpn/test_misc.c
10 files c= hanged, 23 insertions(+), 32 deletions(-)

git pu=
ll ssh://gerrit.openvpn.net:29418/openvpn refs/changes/26/1526/9
di=
ff --git a/src/openvpn/forward.c b/src/openvpn/forward.c
in= dex 27cfd36..e3ba0ed 100644
--- a/src/openvpn/forward.c
+++ b/src/openvpn/forward.c
@@ -482,11 +482,11= @@
if (dco_enabled(&c->options) && dco= _get_peer_stats(c, true) =3D=3D 0)
{
= #ifdef TARGET_FREEBSD
-= int64_t tot_bytes =3D c->c2.dco_read_bytes + c->c2.dco_write_= bytes;
+ count= er_type tot_bytes =3D c->c2.dco_read_bytes + c->c2.dco_write_bytes;
#else
-= int64_t tot_bytes =3D c->c2.tun_read_bytes + c->c2.tun_write_= bytes;
+ count= er_type tot_bytes =3D c->c2.tun_read_bytes + c->c2.tun_write_bytes;
#endif
= - int64_t new_bytes =3D tot_bytes - c->c2.inactivity_bytes;
+ counter_type new_= bytes =3D tot_bytes - c->c2.inactivity_bytes;
if (new_bytes > c->options.inactivity_minimum_bytes)=
{
diff --git a/src/openvpn/forwar= d.h b/src/openvpn/forward.h
index 0d3e492..bedad67 100644
--- a/src/openvpn/forward.h
+++ b/src/openvp= n/forward.h
@@ -347,7 +347,7 @@
}
static inline void
-register_activity(struct context *c, const int64_t = size)
+register_activ= ity(struct context *c, const uint64_t size)
{
if (c->options.inactivity_timeout)

{
diff --git a/src/openvpn/openvpn.h b/src/openvpn/openvpn.h
index fa00822..864c160 100644
--- a/src/openvpn/= openvpn.h
+++ b/src/openvpn/openvpn.h
@@ -2= 85,7 +285,7 @@

/* --inactive */
struct event_timeout inactivity_interval;
- int64_t inactivity_bytes;+ counter_type inactivity_= bytes;

struct event_timeout session_= interval;

diff --git a/src/openvpn/option= s.c b/src/openvpn/options.c
index 713dcf4..0d32b23 100644
--- a/src/openvpn/options.c
+++ b/src/openvp= n/options.c
@@ -864,9 +864,9 @@
o->= replay_time =3D DEFAULT_TIME_BACKTRACK;
o->key_dire= ction =3D KEY_DIRECTION_BIDIRECTIONAL;
o->tls_timeo= ut =3D 2;
- o->re= negotiate_bytes =3D -1;
+ o->renegotiate_bytes =3D 0;
o->renegotia= te_seconds =3D 3600;
- = o->renegotiate_seconds_min =3D -1;
+ o->renegotiate_seconds_min =3D 0;
o->handshake_window =3D 60;

o->transitio= n_window =3D 3600;
o->tls_cert_profile =3D NULL;
@@ -955,7 +955,7 @@
SHOW_PARM(var, o->= ;var##_inline ? "[INLINE]" : (o->var ? o->var : "[UNDE= F]"), "'%s'")
#define SHOW_INT(var)= SHOW_PARM(var, o->var, "%d")
#define SH= OW_UINT(var) SHOW_PARM(var, o->var, "%u")
-#define SHOW_INT64(var) SHOW_PARM(v= ar, o->var, "%" PRIi64)
+#define SHOW_UINT64(var) SHOW_PARM(var, o->var, "= ;%" PRIu64)
#define SHOW_UNSIGNED(var) SHOW_PARM(var,= o->var, "0x%08x")
#define SHOW_BOOL(var) = SHOW_PARM(var, (o->var ? "ENABLED" : "DISABLED"), &= quot;%s");

@@ -1715,7 +1715,7 @@
SHOW_INT(keepalive_timeout);
SHOW_IN= T(inactivity_timeout);
SHOW_INT(session_timeout);
- SHOW_INT64(inactivity_= minimum_bytes);
+ = SHOW_UINT64(inactivity_minimum_bytes);
SHOW_INT(ping_s= end_timeout);
SHOW_INT(ping_rec_timeout);
SHOW_INT(ping_rec_timeout_action);

@@ -1892,8 +189= 2,8 @@

SHOW_INT(tls_timeout);=

- SHOW_I= NT64(renegotiate_bytes);
+ SHOW_UINT64(renegotiate_bytes);
+ SHOW_UINT64(renegotiate_packets);
SHOW_INT(renegotiate_seconds);
=
SHOW_INT(handshake_window);
diff --git a/src= /openvpn/options.h b/src/openvpn/options.h
index 422820c..0= 2b1e98 100644
--- a/src/openvpn/options.h
+= ++ b/src/openvpn/options.h
@@ -341,7 +341,7 @@
int keepalive_timeout;


int = inactivity_timeout; /* --inactive */
- int64_t inactivity_minimum_bytes;
+ uint64_t inactivity_minimum_bytes;

int session_timeout; /* Force-kill = session after n seconds */

@@ -639,8 +639= ,8 @@
int tls_timeout;

/* Data channel key renegotiation parameters */

- int64_t renegotiate_bytes;
= - int64_t renegotiate_packets;=
+ uint64_t renego= tiate_bytes;
+ uin= t64_t renegotiate_packets;
int renegotiate_seconds;
int renegotiate_seconds_min;
diff --git a/src/openvpn/options_util.c b/src/openvpn/options_util.c=
index 47fe0bc..6ea0c7b 100644
--- a/src/op= envpn/options_util.c
+++ b/src/openvpn/options_util.c
@@ -132,7 +132,7 @@
}
<= br> bool
-positiv= e_atoll(const char *str, int64_t *value, const char *name, msglvl_t msgleve= l)
+positive_atoll(co= nst char *str, uint64_t *value, const char *name, msglvl_t msglevel)=
{
char *endptr;
long l= ong ll =3D strtoll(str, &endptr, 10);
@@ -143,7 +143,7 = @@
return false;
}
=
- *value =3D= (int64_t)ll;
+ *v= alue =3D (uint64_t)ll;
return true;
}=

diff --git a/src/openvpn/options_util.h = b/src/openvpn/options_util.h
index 1d4ea9b..1b007fe 100644<= /span>
--- a/src/openvpn/options_util.h
+++ b/src/= openvpn/options_util.h
@@ -48,7 +48,7 @@
= *
* @return \c true if the integer has been parsed and st= ored in value, \c false otherwise
*/
-bool positive_atoll(const char *str, int64= _t *value, const char *name, msglvl_t msglevel);
+bool positive_atoll(const char *str, uint64_t = *value, const char *name, msglvl_t msglevel);

<= span> /**

* Converts a str to an integer if the string ca= n be represented as an
diff --git a/src/openvpn/ssl.c b/src= /openvpn/ssl.c
index 576157d..cf8d644 100644
--- a/src/openvpn/ssl.c

+++ b/src/openvpn/ssl.c@@ -103,11 +103,11 @@
* May *= not* be NULL.
*/
static void
<= span style=3D"color: hsl(0, 100%, 40%);">-tls_limit_reneg_bytes(const char = *ciphername, int64_t *reneg_bytes)

+tls_limit_reneg_bytes(const char *ciphername, uint64_t *rene= g_bytes)
{
if (cipher_kt_insecure(cip= hername))
{
- if (*reneg_bytes =3D=3D -1) /* Not user-specified */
+ if (*reneg_byte= s =3D=3D 0) /* Not user-specified */
{
<= span> msg(M_WARN, "WARNING: cipher with small block size i= n use, "

"reducing reneg= -bytes to 64MB to mitigate SWEET32 attacks.");
@@ -291= 6,11 +2916,6 @@
return true;
}=

-#if define= d(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wsign-compare"=
-#endif
-

/**
* Determines if a renegotiation should be triggerred based on the vario= us

* factors that can trigger one
@@ -294= 2,7 +2937,7 @@
}

= /* Packet limit */
- = if (session->opt->renegotiate_packets && ks->n_packets = >=3D session->opt->renegotiate_packets)
+ if (session->opt->renegotiate_packet= s > 0 && ks->n_packets >=3D session->opt->renegotiat= e_packets)
{
return true;
}
@@ -3000,10 +2995,6 @@
= return false;
}

-#if defined(__GNUC__) || defined(__clang_= _)
-#pragma GCC diagnos= tic pop
-#endif<= br>-
/* * This is the primary routine for processing TLS stuff inside the=
* the main event loop. When this routine exitsdiff --git a/src/openvpn/ssl_common.h b/src/openvpn/ssl_common.h
index 6f310a5..7b35ef3 100644
--- a/src/openv= pn/ssl_common.h
+++ b/src/openvpn/ssl_common.h
@@ -342,8 +342,8 @@

int transition_window;<= br> int handshake_window;
interval_t packet_= timeout;
- int64_t r= enegotiate_bytes;
- = int64_t renegotiate_packets;
+ uint64_t renegotiate_bytes;
+ uint64_t renegotiate_packets;
= /** limit for AEAD cipher when not running in epoch data key mode,<= br> * this is the sum of packets + blocks that are allowed to b= e used */
uint64_t aead_usage_limit;
d= iff --git a/tests/unit_tests/openvpn/test_misc.c b/tests/unit_tests/openvpn= /test_misc.c
index a9ae33f..19303a9 100644
= --- a/tests/unit_tests/openvpn/test_misc.c
+++ b/tests/unit= _tests/openvpn/test_misc.c
@@ -359,7 +359,7 @@
assert_true(atoi_constrained("-1194", &parameter, &q= uot;test", INT_MIN, INT_MAX, msglevel));

assert_i= nt_equal(parameter, -1194);

- int64_t parameter64 =3D 0;
+ uint64_t parameter64 =3D 0; assert_true(positive_atoll("1234", &parameter64,= "test", msglevel));
assert_int_equal(parame= ter64, 1234);
assert_true(positive_atoll("0"= , &parameter64, "test", msglevel));

To view, visit change 1526. To unsubscribe, or for help writing mail= filters, visit = settings.

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I701452496bb47c58b9728b08104= dd5cb7823a94f
Gerrit-Change-Number: 1526
Gerrit-PatchSet: 9
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: cron2 <gert@...1296...>= ;
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
= --X5drm9fmOWc=--