Skip to contentSkip to conversation

Change in openvpn[master]: manage: Change command_line_* API to use size_t for lengths

Openvpn-devel In review flichtenheld (Code Review) 2 participants 6 messages Aug 6, 2025 – Sep 15, 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.1754490554000.Ifc183e42b190e19e1d8c351d1cd460a038626e63@...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/+/1136?usp=email

to review the following change.

Change subject: manage: Change command_line_* API to use size_t for lengths
......................................................................

manage: Change command_line_* API to use size_t for lengths

The used functions already expect this.

Change-Id Ifc183e42b190e19e1d8c351d1cd460a038626e63

---
M src/openvpn/manage.c
M src/openvpn/manage.h

2 files changed, 7 insertions(+), 9 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/36/1136/1

src/openvpn/manage.c +5 -7
index 16b1b73..9750d58 100644
@@ -2247,7 +2247,7 @@
         bool processed_command = false;
 
         ASSERT(len <= (int)sizeof(buf));
-        command_line_add(man->connection.in, buf, len);
+        command_line_add(man->connection.in, buf, (size_t)len);
 
         /*
          * Reset output object
@@ -3786,7 +3786,7 @@
  */
 
 struct command_line *
-command_line_new(const int buf_len)
+command_line_new(const size_t buf_len)
 {
     struct command_line *cl;
     ALLOC_OBJ_CLEAR(cl, struct command_line);
@@ -3816,10 +3816,9 @@
 }
 
 void
-command_line_add(struct command_line *cl, const unsigned char *buf, const int len)
+command_line_add(struct command_line *cl, const unsigned char *buf, const size_t len)
 {
-    int i;
-    for (i = 0; i < len; ++i)
+    for (size_t i = 0; i < len; ++i)
     {
         if (buf[i] && char_class(buf[i], (CC_PRINT | CC_NEWLINE)))
         {
@@ -3834,10 +3833,9 @@
 const char *
 command_line_get(struct command_line *cl)
 {
-    int i;
     const char *ret = NULL;
 
-    i = buf_substring_len(&cl->buf, '\n');
+    int i = buf_substring_len(&cl->buf, '\n');
     if (i >= 0)
     {
         buf_copy_excess(&cl->residual, &cl->buf, i);
src/openvpn/manage.h +2 -2
index 01d180a..e234df7 100644
@@ -83,11 +83,11 @@
     struct buffer residual;
 };
 
-struct command_line *command_line_new(const int buf_len);
+struct command_line *command_line_new(const size_t buf_len);
 
 void command_line_free(struct command_line *cl);
 
-void command_line_add(struct command_line *cl, const unsigned char *buf, const int len);
+void command_line_add(struct command_line *cl, const unsigned char *buf, const size_t len);
 
 const char *command_line_get(struct command_line *cl);
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1136?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: Ifc183e42b190e19e1d8c351d1cd460a038626e63
Gerrit-Change-Number: 1136
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-MessageType: newchange

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

Attention is currently required from: flichtenheld, plaisthos.

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

Change subject: manage: Change command_line_* API to use size_t for lengths
......................................................................

Patch Set 5: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1136?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: Ifc183e42b190e19e1d8c351d1cd460a038626e63
Gerrit-Change-Number: 1136
Gerrit-PatchSet: 5
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Sun, 14 Sep 2025 17:46:17 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#3 lore raw

PATCH v5 1/1 manage: Change command_line_* API to use size_t for lengths

In reply to a message not in the archive

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

The used functions already expect this.

Change-Id Ifc183e42b190e19e1d8c351d1cd460a038626e63

---

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/+/1136
This mail reflects revision 5 of this Change.

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

src/openvpn/manage.c +5 -7
index 16b1b73..9750d58 100644
@@ -2247,7 +2247,7 @@
         bool processed_command = false;
 
         ASSERT(len <= (int)sizeof(buf));
-        command_line_add(man->connection.in, buf, len);
+        command_line_add(man->connection.in, buf, (size_t)len);
 
         /*
          * Reset output object
@@ -3786,7 +3786,7 @@
  */
 
 struct command_line *
-command_line_new(const int buf_len)
+command_line_new(const size_t buf_len)
 {
     struct command_line *cl;
     ALLOC_OBJ_CLEAR(cl, struct command_line);
@@ -3816,10 +3816,9 @@
 }
 
 void
-command_line_add(struct command_line *cl, const unsigned char *buf, const int len)
+command_line_add(struct command_line *cl, const unsigned char *buf, const size_t len)
 {
-    int i;
-    for (i = 0; i < len; ++i)
+    for (size_t i = 0; i < len; ++i)
     {
         if (buf[i] && char_class(buf[i], (CC_PRINT | CC_NEWLINE)))
         {
@@ -3834,10 +3833,9 @@
 const char *
 command_line_get(struct command_line *cl)
 {
-    int i;
     const char *ret = NULL;
 
-    i = buf_substring_len(&cl->buf, '\n');
+    int i = buf_substring_len(&cl->buf, '\n');
     if (i >= 0)
     {
         buf_copy_excess(&cl->residual, &cl->buf, i);
src/openvpn/manage.h +2 -2
index 01d180a..e234df7 100644
@@ -83,11 +83,11 @@
     struct buffer residual;
 };
 
-struct command_line *command_line_new(const int buf_len);
+struct command_line *command_line_new(const size_t buf_len);
 
 void command_line_free(struct command_line *cl);
 
-void command_line_add(struct command_line *cl, const unsigned char *buf, const int len);
+void command_line_add(struct command_line *cl, const unsigned char *buf, const size_t len);
 
 const char *command_line_get(struct command_line *cl);
 
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: manage: Change command_line_* API to use size_t for lengths

Pretty straightforward, and everything still works :-)

Your patch has been applied to the master branch.

commit 5759a838ee630409b44206a60a599041a23c1190

Author: Frank Lichtenheld
Date:   Sun Sep 14 19:46:29 2025 +0200
     manage: Change command_line_* API to use size_t for lengths

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1136
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg32929.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 (#6) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1136?usp=email )

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

Change subject: manage: Change command_line_* API to use size_t for lengths
......................................................................

manage: Change command_line_* API to use size_t for lengths

The used functions already expect this.

Change-Id Ifc183e42b190e19e1d8c351d1cd460a038626e63

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

---
M src/openvpn/manage.c
M src/openvpn/manage.h

2 files changed, 7 insertions(+), 9 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/36/1136/6

src/openvpn/manage.c +5 -7
index 114e4c6..4decdfe 100644
@@ -2334,7 +2334,7 @@
         bool processed_command = false;
 
         ASSERT(len <= (int)sizeof(buf));
-        command_line_add(man->connection.in, buf, len);
+        command_line_add(man->connection.in, buf, (size_t)len);
 
         /*
          * Reset output object
@@ -3873,7 +3873,7 @@
  */
 
 struct command_line *
-command_line_new(const int buf_len)
+command_line_new(const size_t buf_len)
 {
     struct command_line *cl;
     ALLOC_OBJ_CLEAR(cl, struct command_line);
@@ -3903,10 +3903,9 @@
 }
 
 void
-command_line_add(struct command_line *cl, const unsigned char *buf, const int len)
+command_line_add(struct command_line *cl, const unsigned char *buf, const size_t len)
 {
-    int i;
-    for (i = 0; i < len; ++i)
+    for (size_t i = 0; i < len; ++i)
     {
         if (buf[i] && char_class(buf[i], (CC_PRINT | CC_NEWLINE)))
         {
@@ -3921,10 +3920,9 @@
 const char *
 command_line_get(struct command_line *cl)
 {
-    int i;
     const char *ret = NULL;
 
-    i = buf_substring_len(&cl->buf, '\n');
+    int i = buf_substring_len(&cl->buf, '\n');
     if (i >= 0)
     {
         buf_copy_excess(&cl->residual, &cl->buf, i);
src/openvpn/manage.h +2 -2
index 0bce25e..7c189ba 100644
@@ -80,11 +80,11 @@
     struct buffer residual;
 };
 
-struct command_line *command_line_new(const int buf_len);
+struct command_line *command_line_new(const size_t buf_len);
 
 void command_line_free(struct command_line *cl);
 
-void command_line_add(struct command_line *cl, const unsigned char *buf, const int len);
+void command_line_add(struct command_line *cl, const unsigned char *buf, const size_t len);
 
 const char *command_line_get(struct command_line *cl);
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1136?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: Ifc183e42b190e19e1d8c351d1cd460a038626e63
Gerrit-Change-Number: 1136
Gerrit-PatchSet: 6
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

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

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

Change subject: manage: Change command_line_* API to use size_t for lengths
......................................................................

manage: Change command_line_* API to use size_t for lengths

The used functions already expect this.

Change-Id Ifc183e42b190e19e1d8c351d1cd460a038626e63

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

---
M src/openvpn/manage.c
M src/openvpn/manage.h

2 files changed, 7 insertions(+), 9 deletions(-)
src/openvpn/manage.c +5 -7
index 114e4c6..4decdfe 100644
@@ -2334,7 +2334,7 @@
         bool processed_command = false;
 
         ASSERT(len <= (int)sizeof(buf));
-        command_line_add(man->connection.in, buf, len);
+        command_line_add(man->connection.in, buf, (size_t)len);
 
         /*
          * Reset output object
@@ -3873,7 +3873,7 @@
  */
 
 struct command_line *
-command_line_new(const int buf_len)
+command_line_new(const size_t buf_len)
 {
     struct command_line *cl;
     ALLOC_OBJ_CLEAR(cl, struct command_line);
@@ -3903,10 +3903,9 @@
 }
 
 void
-command_line_add(struct command_line *cl, const unsigned char *buf, const int len)
+command_line_add(struct command_line *cl, const unsigned char *buf, const size_t len)
 {
-    int i;
-    for (i = 0; i < len; ++i)
+    for (size_t i = 0; i < len; ++i)
     {
         if (buf[i] && char_class(buf[i], (CC_PRINT | CC_NEWLINE)))
         {
@@ -3921,10 +3920,9 @@
 const char *
 command_line_get(struct command_line *cl)
 {
-    int i;
     const char *ret = NULL;
 
-    i = buf_substring_len(&cl->buf, '\n');
+    int i = buf_substring_len(&cl->buf, '\n');
     if (i >= 0)
     {
         buf_copy_excess(&cl->residual, &cl->buf, i);
src/openvpn/manage.h +2 -2
index 0bce25e..7c189ba 100644
@@ -80,11 +80,11 @@
     struct buffer residual;
 };
 
-struct command_line *command_line_new(const int buf_len);
+struct command_line *command_line_new(const size_t buf_len);
 
 void command_line_free(struct command_line *cl);
 
-void command_line_add(struct command_line *cl, const unsigned char *buf, const int len);
+void command_line_add(struct command_line *cl, const unsigned char *buf, const size_t len);
 
 const char *command_line_get(struct command_line *cl);
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1136?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: Ifc183e42b190e19e1d8c351d1cd460a038626e63
Gerrit-Change-Number: 1136
Gerrit-PatchSet: 6
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged