From: "cron2 (Code Review)" Date: Mon, 15 Dec 2025 16:12:15 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <0ec42a4d5bdd319def0919cf3c684d20d09aa5e0-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="R5WWqcSd+mY="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: buffer: Change buf_prepend and buf_advance to accept ssize_t for length List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld , plaisthos Cc: openvpn-devel --R5WWqcSd+mY= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#2) to the change originally created by= flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1437?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2, Code-Review+2 by plaisthos Change subject: buffer: Change buf_prepend and buf_advance to accept ssize_= t for length ...................................................................... buffer: Change buf_prepend and buf_advance to accept ssize_t for length We already have tests to make sure the value is sane. Changing the argument to ssize_t allows to use it in more places without needing to do a cast before the checks. Change-Id: I123002255b37160d48ef6481f68a89d03073236b Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1437 Message-Id: <20251215160541.24237-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg35= 099.html Signed-off-by: Gert Doering --- M src/openvpn/buffer.c M src/openvpn/buffer.h M src/openvpn/ps.c 3 files changed, 10 insertions(+), 10 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/37/1437/2 diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c index 40baca6..acab06b 100644 --- a/src/openvpn/buffer.c +++ b/src/openvpn/buffer.c @@ -789,7 +789,7 @@ { if (buf_string_match_head_str(src, match)) { - buf_advance(src, (int)strlen(match)); + buf_advance(src, strlen(match)); return true; } else @@ -1312,7 +1312,7 @@ } void -buffer_list_advance(struct buffer_list *ol, int n) +buffer_list_advance(struct buffer_list *ol, ssize_t n) { if (ol->head) { diff --git a/src/openvpn/buffer.h b/src/openvpn/buffer.h index 1dbe0b2..1a6358d 100644 --- a/src/openvpn/buffer.h +++ b/src/openvpn/buffer.h @@ -601,26 +601,26 @@ */ static inline uint8_t * -buf_prepend(struct buffer *buf, int size) +buf_prepend(struct buffer *buf, ssize_t size) { if (!buf_valid(buf) || size < 0 || size > buf->offset) { return NULL; } - buf->offset -=3D size; - buf->len +=3D size; + buf->offset -=3D (int)size; + buf->len +=3D (int)size; return BPTR(buf); } static inline bool -buf_advance(struct buffer *buf, int size) +buf_advance(struct buffer *buf, ssize_t size) { if (!buf_valid(buf) || size < 0 || buf->len < size) { return false; } - buf->offset +=3D size; - buf->len -=3D size; + buf->offset +=3D (int)size; + buf->len -=3D (int)size; return true; } @@ -1187,7 +1187,7 @@ */ struct buffer *buffer_list_peek(struct buffer_list *ol); -void buffer_list_advance(struct buffer_list *ol, int n); +void buffer_list_advance(struct buffer_list *ol, ssize_t n); void buffer_list_pop(struct buffer_list *ol); diff --git a/src/openvpn/ps.c b/src/openvpn/ps.c index 31e7c25..917f871 100644 --- a/src/openvpn/ps.c +++ b/src/openvpn/ps.c @@ -596,7 +596,7 @@ { dmsg(D_PS_PROXY_DEBUG, "PORT SHARE PROXY: partial write[%d], t= ried=3D%d got=3D%zd", (int)sd, pc->buf.len, status); - buf_advance(&pc->buf, (int)status); + buf_advance(&pc->buf, status); return IOSTAT_EAGAIN_ON_WRITE; } else -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1437?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: I123002255b37160d48ef6481f68a89d03073236b Gerrit-Change-Number: 1437 Gerrit-PatchSet: 2 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --R5WWqcSd+mY= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 upl= oaded patch set #2 to the change originally created by flichtenhel= d.

View Change

The following approvals got outdated and were remove= d: Code-Review+2 by cron2, Code-Review+2 by plaisthos

buffer:=
 Change buf_prepend and buf_advance to accept ssize_t for length

We = already have tests to make sure the value is sane.
Changing the argument= to ssize_t allows to use it in
more places without needing to do a cast= before the
checks.

Change-Id: I123002255b37160d48ef6481f68a89d03= 073236b
Signed-off-by: Frank Lichtenheld <frank@...2641...>
Ack= ed-by: Gert Doering <gert@...1296...>
Gerrit URL: https://gerrit.o= penvpn.net/c/openvpn/+/1437
Message-Id: <20251215160541.24237-1-gert@= ...1296...>
URL: https://www.mail-archive.com/openvpn-devel@...1885...= rceforge.net/msg35099.html
Signed-off-by: Gert Doering <gert@...1725...= ..>
---
M src/openvpn/buffer.c
M src/openvpn/buffer.h
M src/= openvpn/ps.c
3 files changed, 10 insertions(+), 10 deletions(-)

<= /pre>
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/cha=
nges/37/1437/2
diff --git a/src/openvpn/buffer.c b/src/openvpn/buff=
er.c
index 40baca6..acab06b 100644
--- a/sr= c/openvpn/buffer.c
+++ b/src/openvpn/buffer.c
@@ -789,7 +789,7 @@
{
if (buf_stri= ng_match_head_str(src, match))
{
- buf_advance(src, (int)strlen(match)= );
+ buf_advan= ce(src, strlen(match));
return true;
}
else
@@ -1312,7 +1312,7 @@
}

void
-buffer_list_advance(struct buffer_list = *ol, int n)
+buffer_l= ist_advance(struct buffer_list *ol, ssize_t n)
{ if (ol->head)
{
diff --= git a/src/openvpn/buffer.h b/src/openvpn/buffer.h
index 1db= e0b2..1a6358d 100644
--- a/src/openvpn/buffer.h
<= span>+++ b/src/openvpn/buffer.h

@@ -601,26 +601,26 @@
*/

static inline uint8_t *<= /span>
-buf_prepend(struct buf= fer *buf, int size)
+= buf_prepend(struct buffer *buf, ssize_t size)
{
= if (!buf_valid(buf) || size < 0 || size > buf->offset)<= /span>
{
return NULL;
}

- buf->o= ffset -=3D size;
- b= uf->len +=3D size;
+ buf->offset -=3D (int)size;
+ buf->len +=3D (int)size;
retur= n BPTR(buf);
}

static i= nline bool
-buf_advance= (struct buffer *buf, int size)
+buf_advance(struct buffer *buf, ssize_t size)
{=
if (!buf_valid(buf) || size < 0 || buf->len <= ; size)
{
return false;
}
- = buf->offset +=3D size;
- buf->len -=3D size;
+ buf->offset +=3D (int)size;
+ buf->len -=3D (int)size;
= return true;
}

@@ -1= 187,7 +1187,7 @@
*/
struct buffer *buffe= r_list_peek(struct buffer_list *ol);

-void buffer_list_advance(struct buffer_lis= t *ol, int n);
+void = buffer_list_advance(struct buffer_list *ol, ssize_t n);

void buffer_list_pop(struct buffer_list *ol);

diff --git a/src/openvpn/ps.c b/src/openvpn/ps.c
index 31e7c25..917f871 100644
--- a/src/openvpn/= ps.c
+++ b/src/openvpn/ps.c
@@ -596,7 +596,= 7 @@
{
dmsg(D_PS_PROX= Y_DEBUG, "PORT SHARE PROXY: partial write[%d], tried=3D%d got=3D%zd&qu= ot;, (int)sd,
pc->buf.len, status);
- buf_advance(= &pc->buf, (int)status);
+ buf_advance(&pc->buf, status);
return IOSTAT_EAGAIN_ON_WRITE;

}
else

To view, vi= sit chan= ge 1437. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I123002255b37160d48ef6481f68= a89d03073236b
Gerrit-Change-Number: 1437
Gerrit-PatchSet: 2
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>
= --R5WWqcSd+mY=--