Skip to contentSkip to conversation

Change in openvpn[master]: ssl: Change tls_send_payload size argument to size_t

Openvpn-devel In review flichtenheld (Code Review) 2 participants 6 messages Nov 7, 2025 – Nov 12, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1762517501000.Ic90c5a0e48bda4a02d5e11c4c161f388cc8805af@...2715...

#1 lore raw

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/+/1355?usp=email

to review the following change.

Change subject: ssl: Change tls_send_payload size argument to size_t
......................................................................

ssl: Change tls_send_payload size argument to size_t

There is only one caller of this function and it wants it to be size_t. So move the size_t to int conversion one step down in the call chain. Do not switch key_state_write_plaintext_const, yet, since that is a backend function and so needs way more work.

Change-Id Ic90c5a0e48bda4a02d5e11c4c161f388cc8805af

---
M src/openvpn/forward.c
M src/openvpn/ssl.c
M src/openvpn/ssl.h

3 files changed, 10 insertions(+), 9 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/55/1355/1

src/openvpn/forward.c +5 -5
index 5bbac13..cffb310 100644
@@ -365,11 +365,6 @@
     }
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 bool
 send_control_channel_string_dowork(struct tls_session *session, const char *str,
                                    msglvl_t msglevel)
@@ -827,6 +822,11 @@
 #endif /* ENABLE_MANAGEMENT */
 }
 
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wconversion"
+#endif
+
 static void
 check_coarse_timers(struct context *c)
 {
src/openvpn/ssl.c +4 -3
index 908854a..398c9ae 100644
@@ -4032,7 +4032,7 @@
  */
 
 bool
-tls_send_payload(struct key_state *ks, const uint8_t *data, int size)
+tls_send_payload(struct key_state *ks, const uint8_t *data, size_t size)
 {
     bool ret = false;
 
@@ -4042,7 +4042,8 @@
 
     if (ks->state >= S_ACTIVE)
     {
-        if (key_state_write_plaintext_const(&ks->ks_ssl, data, size) == 1)
+        ASSERT(size <= INT_MAX);
+        if (key_state_write_plaintext_const(&ks->ks_ssl, data, (int)size) == 1)
         {
             ret = true;
         }
@@ -4053,7 +4054,7 @@
         {
             ks->paybuf = buffer_list_new();
         }
-        buffer_list_push_data(ks->paybuf, data, (size_t)size);
+        buffer_list_push_data(ks->paybuf, data, size);
         ret = true;
     }
 
src/openvpn/ssl.h +1 -1
index ffcc7c4..db8a798 100644
@@ -426,7 +426,7 @@
 /*
  * Send a payload over the TLS control channel
  */
-bool tls_send_payload(struct key_state *ks, const uint8_t *data, int size);
+bool tls_send_payload(struct key_state *ks, const uint8_t *data, size_t size);
 
 /*
  * Receive a payload through the TLS control channel

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

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic90c5a0e48bda4a02d5e11c4c161f388cc8805af
Gerrit-Change-Number: 1355
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld.

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

Change subject: ssl: Change tls_send_payload size argument to size_t
......................................................................

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic90c5a0e48bda4a02d5e11c4c161f388cc8805af
Gerrit-Change-Number: 1355
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 11 Nov 2025 11:52:13 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

#3 lore raw

PATCH 1/1 ssl: Change tls_send_payload size argument to size_t

In reply to a message not in the archive

From: Frank Lichtenheld <[email protected]...>

There is only one caller of this function and it wants it to be size_t. So move the size_t to int conversion one step down in the call chain. Do not switch key_state_write_plaintext_const, yet, since that is a backend function and so needs way more work.

Change-Id Ic90c5a0e48bda4a02d5e11c4c161f388cc8805af

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1355
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1355
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Arne Schwabe <[email protected]...>

src/openvpn/forward.c +5 -5
index 5bbac13..cffb310 100644
@@ -365,11 +365,6 @@
     }
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 bool
 send_control_channel_string_dowork(struct tls_session *session, const char *str,
                                    msglvl_t msglevel)
@@ -827,6 +822,11 @@
 #endif /* ENABLE_MANAGEMENT */
 }
 
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wconversion"
+#endif
+
 static void
 check_coarse_timers(struct context *c)
 {
src/openvpn/ssl.c +4 -3
index 908854a..398c9ae 100644
@@ -4032,7 +4032,7 @@
  */
 
 bool
-tls_send_payload(struct key_state *ks, const uint8_t *data, int size)
+tls_send_payload(struct key_state *ks, const uint8_t *data, size_t size)
 {
     bool ret = false;
 
@@ -4042,7 +4042,8 @@
 
     if (ks->state >= S_ACTIVE)
     {
-        if (key_state_write_plaintext_const(&ks->ks_ssl, data, size) == 1)
+        ASSERT(size <= INT_MAX);
+        if (key_state_write_plaintext_const(&ks->ks_ssl, data, (int)size) == 1)
         {
             ret = true;
         }
@@ -4053,7 +4054,7 @@
         {
             ks->paybuf = buffer_list_new();
         }
-        buffer_list_push_data(ks->paybuf, data, (size_t)size);
+        buffer_list_push_data(ks->paybuf, data, size);
         ret = true;
     }
 
src/openvpn/ssl.h +1 -1
index ffcc7c4..db8a798 100644
@@ -426,7 +426,7 @@
 /*
  * Send a payload over the TLS control channel
  */
-bool tls_send_payload(struct key_state *ks, const uint8_t *data, int size);
+bool tls_send_payload(struct key_state *ks, const uint8_t *data, size_t size);
 
 /*
  * Receive a payload through the TLS control channel
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: ssl: Change tls_send_payload size argument to size_t

"Because it makes sense" :-) - stared at the code, +2 from Arne, BB all green.

Your patch has been applied to the master branch.

commit 0da6116c0c8fccfa12369139ebf9357d113debba

Author: Frank Lichtenheld
Date:   Tue Nov 11 16:52:31 2025 +0100
     ssl: Change tls_send_payload size argument to size_t

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: Arne Schwabe <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1355
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg34320.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1355?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by plaisthos

Change subject: ssl: Change tls_send_payload size argument to size_t
......................................................................

ssl: Change tls_send_payload size argument to size_t

There is only one caller of this function and it wants it to be size_t. So move the size_t to int conversion one step down in the call chain. Do not switch key_state_write_plaintext_const, yet, since that is a backend function and so needs way more work.

Change-Id Ic90c5a0e48bda4a02d5e11c4c161f388cc8805af

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1355
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34320.html

---
M src/openvpn/forward.c
M src/openvpn/ssl.c
M src/openvpn/ssl.h

3 files changed, 10 insertions(+), 9 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/55/1355/2

src/openvpn/forward.c +5 -5
index c355f66..aa1f858 100644
@@ -365,11 +365,6 @@
     }
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 bool
 send_control_channel_string_dowork(struct tls_session *session, const char *str,
                                    msglvl_t msglevel)
@@ -834,6 +829,11 @@
 #endif /* ENABLE_MANAGEMENT */
 }
 
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wconversion"
+#endif
+
 static void
 check_coarse_timers(struct context *c)
 {
src/openvpn/ssl.c +4 -3
index 908854a..398c9ae 100644
@@ -4032,7 +4032,7 @@
  */
 
 bool
-tls_send_payload(struct key_state *ks, const uint8_t *data, int size)
+tls_send_payload(struct key_state *ks, const uint8_t *data, size_t size)
 {
     bool ret = false;
 
@@ -4042,7 +4042,8 @@
 
     if (ks->state >= S_ACTIVE)
     {
-        if (key_state_write_plaintext_const(&ks->ks_ssl, data, size) == 1)
+        ASSERT(size <= INT_MAX);
+        if (key_state_write_plaintext_const(&ks->ks_ssl, data, (int)size) == 1)
         {
             ret = true;
         }
@@ -4053,7 +4054,7 @@
         {
             ks->paybuf = buffer_list_new();
         }
-        buffer_list_push_data(ks->paybuf, data, (size_t)size);
+        buffer_list_push_data(ks->paybuf, data, size);
         ret = true;
     }
 
src/openvpn/ssl.h +1 -1
index ffcc7c4..db8a798 100644
@@ -426,7 +426,7 @@
 /*
  * Send a payload over the TLS control channel
  */
-bool tls_send_payload(struct key_state *ks, const uint8_t *data, int size);
+bool tls_send_payload(struct key_state *ks, const uint8_t *data, size_t size);
 
 /*
  * Receive a payload through the TLS control channel

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

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic90c5a0e48bda4a02d5e11c4c161f388cc8805af
Gerrit-Change-Number: 1355
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1355?usp=email )

Change subject: ssl: Change tls_send_payload size argument to size_t
......................................................................

ssl: Change tls_send_payload size argument to size_t

There is only one caller of this function and it wants it to be size_t. So move the size_t to int conversion one step down in the call chain. Do not switch key_state_write_plaintext_const, yet, since that is a backend function and so needs way more work.

Change-Id Ic90c5a0e48bda4a02d5e11c4c161f388cc8805af

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1355
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34320.html

---
M src/openvpn/forward.c
M src/openvpn/ssl.c
M src/openvpn/ssl.h

3 files changed, 10 insertions(+), 9 deletions(-)
src/openvpn/forward.c +5 -5
index c355f66..aa1f858 100644
@@ -365,11 +365,6 @@
     }
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 bool
 send_control_channel_string_dowork(struct tls_session *session, const char *str,
                                    msglvl_t msglevel)
@@ -834,6 +829,11 @@
 #endif /* ENABLE_MANAGEMENT */
 }
 
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wconversion"
+#endif
+
 static void
 check_coarse_timers(struct context *c)
 {
src/openvpn/ssl.c +4 -3
index 908854a..398c9ae 100644
@@ -4032,7 +4032,7 @@
  */
 
 bool
-tls_send_payload(struct key_state *ks, const uint8_t *data, int size)
+tls_send_payload(struct key_state *ks, const uint8_t *data, size_t size)
 {
     bool ret = false;
 
@@ -4042,7 +4042,8 @@
 
     if (ks->state >= S_ACTIVE)
     {
-        if (key_state_write_plaintext_const(&ks->ks_ssl, data, size) == 1)
+        ASSERT(size <= INT_MAX);
+        if (key_state_write_plaintext_const(&ks->ks_ssl, data, (int)size) == 1)
         {
             ret = true;
         }
@@ -4053,7 +4054,7 @@
         {
             ks->paybuf = buffer_list_new();
         }
-        buffer_list_push_data(ks->paybuf, data, (size_t)size);
+        buffer_list_push_data(ks->paybuf, data, size);
         ret = true;
     }
 
src/openvpn/ssl.h +1 -1
index ffcc7c4..db8a798 100644
@@ -426,7 +426,7 @@
 /*
  * Send a payload over the TLS control channel
  */
-bool tls_send_payload(struct key_state *ks, const uint8_t *data, int size);
+bool tls_send_payload(struct key_state *ks, const uint8_t *data, size_t size);
 
 /*
  * Receive a payload through the TLS control channel

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

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic90c5a0e48bda4a02d5e11c4c161f388cc8805af
Gerrit-Change-Number: 1355
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>