From: Frank Lichtenheld Date: Thu, 22 Jan 2026 12:58:28 +0000 (+0100) Subject: ssl_ncp: Avoid conversion warning in replace_default_in_ncp_ciphers_option X-Git-Tag: v2.7_rc6~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b28321edfe65290fae6d09d931aa36187ad95e95;p=thirdparty%2Fopenvpn.git ssl_ncp: Avoid conversion warning in replace_default_in_ncp_ciphers_option Change-Id: I380e842b7429060d13bc0264e55fa5c06ab427df Signed-off-by: Frank Lichtenheld Acked-by: Arne Schwabe Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1452 Message-Id: <20260122125829.108470-1-frank@lichtenheld.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg35391.html Signed-off-by: Gert Doering --- diff --git a/src/openvpn/ssl_ncp.c b/src/openvpn/ssl_ncp.c index 1a2405c6b..20fd2f04e 100644 --- a/src/openvpn/ssl_ncp.c +++ b/src/openvpn/ssl_ncp.c @@ -534,11 +534,6 @@ check_session_cipher(struct tls_session *session, struct options *options) } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - /** * Replaces the string DEFAULT with the string \c replace. * @@ -549,12 +544,13 @@ static void replace_default_in_ncp_ciphers_option(struct options *o, const char *replace) { const char *search = "DEFAULT"; - const int ncp_ciphers_len = strlen(o->ncp_ciphers) + strlen(replace) - strlen(search) + 1; + const size_t ncp_ciphers_len = strlen(o->ncp_ciphers) + strlen(replace) - strlen(search) + 1; uint8_t *ncp_ciphers = gc_malloc(ncp_ciphers_len, true, &o->gc); struct buffer ncp_ciphers_buf; - buf_set_write(&ncp_ciphers_buf, ncp_ciphers, ncp_ciphers_len); + ASSERT(ncp_ciphers_len <= INT_MAX); + buf_set_write(&ncp_ciphers_buf, ncp_ciphers, (int)ncp_ciphers_len); const char *def = strstr(o->ncp_ciphers, search); @@ -571,10 +567,6 @@ replace_default_in_ncp_ciphers_option(struct options *o, const char *replace) o->ncp_ciphers = (char *)ncp_ciphers; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - /** * Checks for availibility of Chacha20-Poly1305 and sets * the ncp_cipher to either AES-256-GCM:AES-128-GCM or