From: "plaisthos (Code Review)" Date: Mon, 8 Jul 2024 16:18:06 +0000 In-Reply-To: References: Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <5264fd13b301501f749e875e1ac991de423cd26e-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="uJo9IpBeT20="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Allow trailing \r and \n in control channel message List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: openvpn-devel --uJo9IpBeT20= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld. Hello flichtenheld,=20 I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/672?usp=3Demail to look at the new patch set (#2). The following approvals got outdated and were removed: Code-Review-1 by flichtenheld Change subject: Allow trailing \r and \n in control channel message ...................................................................... Allow trailing \r and \n in control channel message Writing a reason from a script will easily end up adding extra \r\n charact= ers at the end of the reason. Our current code pushes this to the peer. So be m= ore liberal in accepting these message. Closes openvpn/openvpn#568 Change-Id: I47c992b6b73b1475cbff8a28f720cf50dc1fbe3e Signed-off-by: Arne Schwabe --- M src/openvpn/forward.c 1 file changed, 9 insertions(+), 6 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/72/672/2 diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 71b7167..943ed11 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -290,7 +290,6 @@ struct buffer buf =3D alloc_buf_gc(len, &gc); if (tls_rec_payload(c->c2.tls_multi, &buf)) { - while (BLEN(&buf) > 1) { /* commands on the control channel are seperated by 0x00 bytes. @@ -300,19 +299,23 @@ if (cmdlen < BLEN(&buf)) { /* include the NUL byte and ensure NUL termination */ - int cmdlen =3D (int)strlen(BSTR(&buf)) + 1; + int buflen =3D (int)strlen(BSTR(&buf)) + 1; /* Construct a buffer that only holds the current command = and * its closing NUL byte */ - struct buffer cmdbuf =3D alloc_buf_gc(cmdlen, &gc); - buf_write(&cmdbuf, BPTR(&buf), cmdlen); + struct buffer cmdbuf =3D alloc_buf_gc(buflen, &gc); + buf_write(&cmdbuf, BPTR(&buf), buflen); + + /* Remove \r and \n at the end of the buffer to avoid + * problems with scripts and other that add extra \r and \= n */ + buf_chomp(&cmdbuf); /* check we have only printable characters or null byte in= the * command string and no newlines */ - if (!string_check_buf(&buf, CC_PRINT | CC_NULL, CC_CRLF)) + if (!string_check_buf(&cmdbuf, CC_PRINT | CC_NULL, CC_CRLF= )) { msg(D_PUSH_ERRORS, "WARNING: Received control with inv= alid characters: %s", - format_hex(BPTR(&buf), BLEN(&buf), 256, &gc)); + format_hex(BPTR(&buf), BLEN(&cmdbuf), 256, &gc)); } else { -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/672?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: I47c992b6b73b1475cbff8a28f720cf50dc1fbe3e Gerrit-Change-Number: 672 Gerrit-PatchSet: 2 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-Attention: flichtenheld Gerrit-MessageType: newpatchset --uJo9IpBeT20= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld.

plaisthos uploaded patch set #2 to this change.

<= a href=3D"http://gerrit.openvpn.net/c/openvpn/+/672?usp=3Demail">View Chang= e

The following approvals got outdated and were removed: Code-Review-1 by flichtenheld

Allow trailing \r and \n in control channel m=
essage

Writing a reason from a script will easily end up adding extr= a \r\n characters
at the end of the reason. Our current code pushes this= to the peer. So be more
liberal in accepting these message.

Clos= es openvpn/openvpn#568

Change-Id: I47c992b6b73b1475cbff8a28f720cf50d= c1fbe3e
Signed-off-by: Arne Schwabe <arne@...1227...>
---
M = src/openvpn/forward.c
1 file changed, 9 insertions(+), 6 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/72/672=
/2
diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c
index 71b7167..943ed11 100644
--- a/src/openvpn/= forward.c
+++ b/src/openvpn/forward.c
@@ -2= 90,7 +290,6 @@
struct buffer buf =3D alloc_buf_gc(len,= &gc);
if (tls_rec_payload(c->c2.tls_multi, &am= p;buf))
{
-
while (BLEN(&buf) > 1)
= {
/* commands on the control ch= annel are seperated by 0x00 bytes.
@@ -300,19 +299,23 @@
if (cmdlen < BLEN(&buf))
= {
/* include the NUL byte and= ensure NUL termination */
- int cmdlen =3D (int)strlen(BSTR(&buf)) + 1;=
+ int buflen= =3D (int)strlen(BSTR(&buf)) + 1;

= /* Construct a buffer that only holds the current command and=
* its closing NUL byte */
- struct buffer cmdbuf= =3D alloc_buf_gc(cmdlen, &gc);

- buf_write(&cmdbuf, BPTR(&buf), cmdlen= );
+ s= truct buffer cmdbuf =3D alloc_buf_gc(buflen, &gc);
+ buf_write(&cmdbuf, B= PTR(&buf), buflen);
+
+ = /* Remove \r and \n at the end of the buffer to avoid
+ * problems with scripts= and other that add extra \r and \n */
+ buf_chomp(&cmdbuf);
=
/* check we have only printable characte= rs or null byte in the
* command string a= nd no newlines */
- = if (!string_check_buf(&buf, CC_PRINT | CC_NULL, CC_CRLF))
+ if (!= string_check_buf(&cmdbuf, CC_PRINT | CC_NULL, CC_CRLF))
{

msg(D_PUSH_ERRORS,= "WARNING: Received control with invalid characters: %s",<= br>- forma= t_hex(BPTR(&buf), BLEN(&buf), 256, &gc));
+ format_hex(BPTR(&= amp;buf), BLEN(&cmdbuf), 256, &gc));
= }
else
= {

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I47c992b6b73b1475cbff8a28f72= 0cf50dc1fbe3e
Gerrit-Change-Number: 672
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newpatchset
--uJo9IpBeT20=--