From: "flichtenheld (Code Review)" Date: Wed, 6 Aug 2025 14:29:41 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="+mrtQ9ZVetw="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: manage: Change command_line_* API to use size_t for lengths List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --+mrtQ9ZVetw= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=3Demail 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 Signed-off-by: Frank Lichtenheld --- 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 diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index 16b1b73..9750d58 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -2247,7 +2247,7 @@ bool processed_command =3D false; ASSERT(len <=3D (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 =3D 0; i < len; ++i) + for (size_t i =3D 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 =3D NULL; - i =3D buf_substring_len(&cl->buf, '\n'); + int i =3D buf_substring_len(&cl->buf, '\n'); if (i >=3D 0) { buf_copy_excess(&cl->residual, &cl->buf, i); diff --git a/src/openvpn/manage.h b/src/openvpn/manage.h index 01d180a..e234df7 100644 --- a/src/openvpn/manage.h +++ b/src/openvpn/manage.h @@ -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, c= onst int len); +void command_line_add(struct command_line *cl, const unsigned char *buf, c= onst size_t len); const char *command_line_get(struct command_line *cl); -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1136?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ifc183e42b190e19e1d8c351d1cd460a038626e63 Gerrit-Change-Number: 1136 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-MessageType: newchange --+mrtQ9ZVetw= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: plaisthos.

flichtenheld would like plaisthos to review this change.

V= iew Change

manage: Change command_line_* API to use size_t for lengths<=
br>
The used functions already expect this.

Change-Id: Ifc183e42b= 190e19e1d8c351d1cd460a038626e63
Signed-off-by: Frank Lichtenheld <fra= nk@...2641...>
---
M src/openvpn/manage.c
M src/openvpn/manage.= h
2 files changed, 7 insertions(+), 9 deletions(-)

git pull ss=
h://gerrit.openvpn.net:29418/openvpn refs/changes/36/1136/1
diff --=
git a/src/openvpn/manage.c b/src/openvpn/manage.c
index 16b= 1b73..9750d58 100644
--- a/src/openvpn/manage.c
<= span>+++ b/src/openvpn/manage.c
@@ -2247,7 +2247,7 @@
bool processed_command =3D false;

ASSERT(len <=3D (int)sizeof(buf));
- command_line_add(man->conn= ection.in, buf, len);

+ command_line_add(man->connection.in, buf, (size_t)len);=

/*
* Reset o= utput object
@@ -3786,7 +3786,7 @@
*/

struct command_line *
-command_line_new(const int buf_len)<= br>+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_l= ine_add(struct command_line *cl, const unsigned char *buf, const int len)
+command_line_add(stru= ct command_line *cl, const unsigned char *buf, const size_t len)
= {
- int i;
- for (i =3D 0; i <= len; ++i)
+ for (= size_t i =3D 0; i < len; ++i)
{
= if (buf[i] && char_class(buf[i], (CC_PRINT | CC_NEWLINE)))
{
@@ -3834,10 +3833,9 @@
<= span> const char *

command_line_get(struct command_line *c= l)
{
-= int i;
const char *ret =3D NULL;
=
- i =3D buf_substri= ng_len(&cl->buf, '\n');
+ int i =3D buf_substring_len(&cl->buf, '\n= ');
if (i >=3D 0)
{=
buf_copy_excess(&cl->residual, &cl->buf, i= );
diff --git a/src/openvpn/manage.h b/src/openvpn/manage.h=
index 01d180a..e234df7 100644
--- a/src/op= envpn/manage.h
+++ b/src/openvpn/manage.h
@= @ -83,11 +83,11 @@
struct buffer residual;
<= span> };


-struct command_line *command_line_new(const int buf_len);
+struct command_line *command_lin= e_new(const size_t buf_len);


void comman= d_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 change 1136. To unsubscri= be, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ifc183e42b190e19e1d8c351d1cd= 460a038626e63
Gerrit-Change-Number: 1136
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <frank@...2723...= .>
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-MessageType: newchange
--+mrtQ9ZVetw=--