From: "flichtenheld (Code Review)" Date: Fri, 8 Aug 2025 12:34:18 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <3f3f29d6997179a83c0e42b1072f66c07e1445f4-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="Lp4H+IX3dBM="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: buffer: Clarify usage of char_class List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --Lp4H+IX3dBM= 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/+/1142?usp=3Demail to review the following change. Change subject: buffer: Clarify usage of char_class ...................................................................... buffer: Clarify usage of char_class Silence compiler warnings due to conversion from char to unsigned char. In this case we actually depend on this conversion. Change-Id: I73bc163d48b2d6a954cd231961826f33143fcd12 Signed-off-by: Frank Lichtenheld --- M src/openvpn/buffer.c 1 file changed, 11 insertions(+), 2 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/42/1142/1 diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c index 3dd8b31..ca2e3aa 100644 --- a/src/openvpn/buffer.c +++ b/src/openvpn/buffer.c @@ -560,7 +560,7 @@ { break; } - if (char_class(*last, CC_CRLF | CC_NULL)) + if (char_class((unsigned char)*last, CC_CRLF | CC_NULL)) { if (!buf_inc_len(buf, -1)) { @@ -872,6 +872,14 @@ * Classify and mutate strings based on character types. */ +/* Note 1: This functions depends on getting an unsigned + char. Both the is*() functions and our own checks expect it + this way. + Note 2: For CC_PRINT we just accept everything >=3D 32, so + if we ingest non-ASCII UTF-8 we will classify it as + printable since it will be >=3D 128. Other encodings are + not officially supported. +*/ bool char_class(const unsigned char c, const unsigned int flags) { @@ -1015,7 +1023,8 @@ static inline bool char_inc_exc(const char c, const unsigned int inclusive, const unsigned in= t exclusive) { - return char_class(c, inclusive) && !char_class(c, exclusive); + return char_class((unsigned char)c, inclusive) + && !char_class((unsigned char)c, exclusive); } bool -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1142?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: I73bc163d48b2d6a954cd231961826f33143fcd12 Gerrit-Change-Number: 1142 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-MessageType: newchange --Lp4H+IX3dBM= 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

buffer: Clarify usage of char_class

Silence compiler = warnings due to conversion from
char to unsigned char. In this case we a= ctually
depend on this conversion.

Change-Id: I73bc163d48b2d6a954= cd231961826f33143fcd12
Signed-off-by: Frank Lichtenheld <frank@...2716...= 1...>
---
M src/openvpn/buffer.c
1 file changed, 11 insertions(= +), 2 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvp=
n refs/changes/42/1142/1
diff --git a/src/openvpn/buffer.c b/src/op=
envpn/buffer.c
index 3dd8b31..ca2e3aa 100644
--- a/src/openvpn/buffer.c
+++ b/src/openvpn/buffer.c
@@ -560,7 +560,7 @@
{
break;

}
- if (char_class(*last, CC_CRLF | CC_NULL))=
+ if (char_cl= ass((unsigned char)*last, CC_CRLF | CC_NULL))
{
if (!buf_inc_len(buf, -1))
= {
@@ -872,6 +872,14 @@
* Classify= and mutate strings based on character types.
*/
+/* Note 1:= This functions depends on getting an unsigned
+ char. Both the is*() functions and our own ch= ecks expect it
+ th= is way.
+ Note 2: F= or CC_PRINT we just accept everything >=3D 32, so
+ if we ingest non-ASCII UTF-8 we will c= lassify it as
+ pri= ntable since it will be >=3D 128. Other encodings are
+ not officially supported.+*/
bool

char_class(const unsigned char c, const unsigned int flags)
{
@@ -1015,7 +1023,8 @@
sta= tic inline bool
char_inc_exc(const char c, const unsigned = int inclusive, const unsigned int exclusive)
{
<= span style=3D"color: hsl(0, 100%, 40%);">- return char_class(c, inclusiv= e) && !char_class(c, exclusive);

+ return char_class((unsigned char)c, inclusive)
+ && != char_class((unsigned char)c, exclusive);
}

bool

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I73bc163d48b2d6a954cd2319618= 26f33143fcd12
Gerrit-Change-Number: 1142
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
--Lp4H+IX3dBM=--