From: "cron2 (Code Review)" Date: Wed, 4 Mar 2026 16:20:50 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <1d0810771fbf3de4de7c702d9f86d3325b5058a2-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="Ww6Gdr1fM+Q="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: ssl_ncp: Fix length check in mutate_ncp_cipher_list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld , plaisthos Cc: openvpn-devel --Ww6Gdr1fM+Q= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#6) to the change originally created by= flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1503?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by plaisthos Change subject: ssl_ncp: Fix length check in mutate_ncp_cipher_list ...................................................................... ssl_ncp: Fix length check in mutate_ncp_cipher_list * Make it more readable by removing a level of negation * Fix an off-by-one error. It accepted one char fewer than allowed. * Slightly improve the UT. Change-Id: Ib0d2b9520e4a77a9f4bf70ce092f76ca73608537 Signed-off-by: Frank Lichtenheld Acked-by: Arne Schwabe Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1503 Message-Id: <20260302181627.29008-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg35= 828.html Signed-off-by: Gert Doering --- M src/openvpn/ssl_ncp.c M tests/unit_tests/openvpn/test_ncp.c 2 files changed, 18 insertions(+), 14 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/03/1503/6 diff --git a/src/openvpn/ssl_ncp.c b/src/openvpn/ssl_ncp.c index 500e09d..fdac6925 100644 --- a/src/openvpn/ssl_ncp.c +++ b/src/openvpn/ssl_ncp.c @@ -92,11 +92,6 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif - char * mutate_ncp_cipher_list(const char *list, struct gc_arena *gc) { @@ -168,7 +163,7 @@ } /* Ensure buffer has capacity for cipher name + : + \0 */ - if (!(buf_forward_capacity(&new_list) > strlen(ovpn_cipher_nam= e) + 2)) + if (buf_forward_capacity(&new_list) < (int)strlen(ovpn_cipher_= name) + 2) { msg(M_WARN, "Length of --data-ciphers is over the " "limit of 127 chars"); @@ -207,10 +202,6 @@ o->ncp_ciphers =3D ncp_ciphers; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - bool tls_item_in_cipher_list(const char *item, const char *list) { diff --git a/tests/unit_tests/openvpn/test_ncp.c b/tests/unit_tests/openvpn= /test_ncp.c index 9f569a7..52a41ee 100644 --- a/tests/unit_tests/openvpn/test_ncp.c +++ b/tests/unit_tests/openvpn/test_ncp.c @@ -123,10 +123,23 @@ assert_ptr_equal(mutate_ncp_cipher_list("AES-256-GCM:vollbit", &gc), N= ULL); assert_ptr_equal(mutate_ncp_cipher_list("", &gc), NULL); =20 - assert_ptr_equal(mutate_ncp_cipher_list("ChaCha20-Poly1305:ChaCha20-Po= ly1305:ChaCha20-Poly1305:" - "ChaCha20-Poly1305:ChaCha20-Po= ly1305:ChaCha20-Poly1305:" - "ChaCha20-Poly1305", - &gc), + const char long_string[MAX_NCP_CIPHERS_LENGTH] =3D + "CHACHA20-POLY1305:CHACHA20-POLY1305:CHACHA20-POLY1305:" + "CHACHA20-POLY1305:CHACHA20-POLY1305:CHACHA20-POLY1305:" + "CHACHA20-POLY1305"; + const char longer_string[MAX_NCP_CIPHERS_LENGTH + 1] =3D + "CHACHA20-POLY1305:CHACHA20-POLY1305:CHACHA20-POLY1305:" + "CHACHA20-POLY1305:CHACHA20-POLY1305:CHACHA20-POLY1305:" + "CHACHA20-POLY1305:"; + const char longest_string[] =3D + "CHACHA20-POLY1305:CHACHA20-POLY1305:CHACHA20-POLY1305:" + "CHACHA20-POLY1305:CHACHA20-POLY1305:CHACHA20-POLY1305:" + "CHACHA20-POLY1305:CHACHA20-POLY1305"; + assert_string_equal(mutate_ncp_cipher_list(long_string, &gc), + long_string); + assert_string_equal(mutate_ncp_cipher_list(longer_string, &gc), + long_string); + assert_ptr_equal(mutate_ncp_cipher_list(longest_string, &gc), NULL); #ifdef ENABLE_CRYPTO_OPENSSL -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1503?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: Ib0d2b9520e4a77a9f4bf70ce092f76ca73608537 Gerrit-Change-Number: 1503 Gerrit-PatchSet: 6 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --Ww6Gdr1fM+Q= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

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

View Change

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

ssl_ncp: Fix length check in mu=
tate_ncp_cipher_list

* Make it more readable by removing a level of = negation
* Fix an off-by-one error. It accepted one char fewer than
= allowed.
* Slightly improve the UT.

Change-Id: Ib0d2b9520e4a77a9= f4bf70ce092f76ca73608537
Signed-off-by: Frank Lichtenheld <frank@...1665...= 641...>
Acked-by: Arne Schwabe <arne-openvpn@...1227...>
Ger= rit URL: https://gerrit.openvpn.net/c/openvpn/+/1503
Message-Id: <202= 60302181627.29008-1-gert@...1296...>
URL: https://www.mail-archive.co= m/openvpn-devel@lists.sourceforge.net/msg35828.html
Signed-off-by: Gert = Doering <gert@...1296...>
---
M src/openvpn/ssl_ncp.c
M test= s/unit_tests/openvpn/test_ncp.c
2 files changed, 18 insertions(+), 14 de= letions(-)

git pull ssh://gerrit.openvpn.net:294=
18/openvpn refs/changes/03/1503/6
diff --git a/src/openvpn/ssl_ncp.=
c b/src/openvpn/ssl_ncp.c
index 500e09d..fdac6925 100644
--- a/src/openvpn/ssl_ncp.c
+++ b/src/openvpn= /ssl_ncp.c
@@ -92,11 +92,6 @@
}=
}

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "= -Wsign-compare"

-#= endif
-
char *
mutate_ncp_cipher_list(const char *list, struct g= c_arena *gc)
{
@@ -168,7 +163,7 @@<= br> }

/* E= nsure buffer has capacity for cipher name + : + \0 */
- if (!(buf_forward_capacity(&= ;new_list) > strlen(ovpn_cipher_name) + 2))
+ if (buf_forward_capacity(&new_li= st) < (int)strlen(ovpn_cipher_name) + 2)
{<= /span>
msg(M_WARN, "Length of --data-ciphers= is over the "
"limi= t of 127 chars");
@@ -207,10 +202,6 @@
o->ncp_ciphers =3D ncp_ciphers;

}

-#if defined(__GNUC_= _) || defined(__clang__)
-#endif
-=
bool
tls_item_in_cipher_list(const char *item, = const char *list)
{
diff --git a/tests/uni= t_tests/openvpn/test_ncp.c b/tests/unit_tests/openvpn/test_ncp.c
= index 9f569a7..52a41ee 100644
--- a/tests/unit_tests/= openvpn/test_ncp.c
+++ b/tests/unit_tests/openvpn/test_ncp.= c
@@ -123,10 +123,23 @@
assert_ptr_equ= al(mutate_ncp_cipher_list("AES-256-GCM:vollbit", &gc), NULL);=
assert_ptr_equal(mutate_ncp_cipher_list("",= &gc), NULL);

- assert_ptr_equal(mutate_ncp_cipher_list("ChaCha20-Po= ly1305:ChaCha20-Poly1305:ChaCha20-Poly1305:"
- &qu= ot;ChaCha20-Poly1305:ChaCha20-Poly1305:ChaCha20-Poly1305:"
<= span style=3D"color: hsl(0, 100%, 40%);">- = "ChaCha20-Poly1305",
- &gc),
+ const char long_s= tring[MAX_NCP_CIPHERS_LENGTH] =3D
+ "CHACHA20-POLY1305:CHACHA20-POLY1305:CHACHA20-PO= LY1305:"
+ = "CHACHA20-POLY1305:CHACHA20-POLY1305:CHACHA20-POLY1305:"=
+ "CHACHA20-POL= Y1305";
+ con= st char longer_string[MAX_NCP_CIPHERS_LENGTH + 1] =3D
+ "CHACHA20-POLY1305:CHACHA20-= POLY1305:CHACHA20-POLY1305:"
+ "CHACHA20-POLY1305:CHACHA20-POLY1305:CHACHA20-PO= LY1305:"
+ = "CHACHA20-POLY1305:";
+ const char longest_string[] =3D
+ "CHACHA20-POLY1305:CHACHA20-POLY= 1305:CHACHA20-POLY1305:"
+ "CHACHA20-POLY1305:CHACHA20-POLY1305:CHACHA20-POLY13= 05:"
+ &q= uot;CHACHA20-POLY1305:CHACHA20-POLY1305";
+ assert_string_equal(mutate_ncp_cipher_list(l= ong_string, &gc),
+ long_string);
+ assert_string_equal(mutate_ncp_cipher_list(longer_s= tring, &gc),
+ = long_string);
+ assert_ptr_equal(mutate_ncp_cipher_list(longest_string, = &gc),
NULL);

#ifdef ENABLE_CRYPTO_OPENSSL

To view, visit change 1503. To unsubscribe, or for help writing mail filte= rs, visit settin= gs.

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib0d2b9520e4a77a9f4bf70ce092= f76ca73608537
Gerrit-Change-Number: 1503
Gerrit-PatchSet: 6
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --Ww6Gdr1fM+Q=--