From: "flichtenheld (Code Review)" Date: Fri, 26 Sep 2025 12:45:31 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="CiFh8bj5i0A="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: dco_win: In dco_new_key, document size assumptions for the integer casts List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --CiFh8bj5i0A= 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/+/1221?usp=3Demail to review the following change. Change subject: dco_win: In dco_new_key, document size assumptions for the = integer casts ...................................................................... dco_win: In dco_new_key, document size assumptions for the integer casts And make all casts explicit so that compiler doesn't complain. Change-Id: I612bf3b1c56d70a89fc04fad6fe36fd9fadfd258 Signed-off-by: Frank Lichtenheld --- M src/openvpn/dco_win.c 1 file changed, 5 insertions(+), 12 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/21/1221/1 diff --git a/src/openvpn/dco_win.c b/src/openvpn/dco_win.c index 9e52859..7dd43d6 100644 --- a/src/openvpn/dco_win.c +++ b/src/openvpn/dco_win.c @@ -525,11 +525,6 @@ return 0; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - int dco_new_key(dco_context_t *dco, unsigned int peerid, int keyid, dco_key_sl= ot_t slot, const uint8_t *encrypt_key, const uint8_t *encrypt_iv, const u= int8_t *decrypt_key, @@ -540,21 +535,23 @@ const int nonce_len =3D 8; size_t key_len =3D cipher_kt_key_size(ciphername); + ASSERT(key_len <=3D 32); OVPN_CRYPTO_DATA crypto_data; ZeroMemory(&crypto_data, sizeof(crypto_data)); crypto_data.CipherAlg =3D dco_get_cipher(ciphername); - crypto_data.KeyId =3D keyid; + ASSERT(keyid > 0 && keyid <=3D UCHAR_MAX); + crypto_data.KeyId =3D (unsigned char)keyid; crypto_data.PeerId =3D peerid; crypto_data.KeySlot =3D slot; CopyMemory(crypto_data.Encrypt.Key, encrypt_key, key_len); - crypto_data.Encrypt.KeyLen =3D (char)key_len; + crypto_data.Encrypt.KeyLen =3D (unsigned char)key_len; CopyMemory(crypto_data.Encrypt.NonceTail, encrypt_iv, nonce_len); CopyMemory(crypto_data.Decrypt.Key, decrypt_key, key_len); - crypto_data.Decrypt.KeyLen =3D (char)key_len; + crypto_data.Decrypt.KeyLen =3D (unsigned char)key_len; CopyMemory(crypto_data.Decrypt.NonceTail, decrypt_iv, nonce_len); ASSERT(crypto_data.CipherAlg > 0); @@ -570,10 +567,6 @@ return 0; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - int dco_del_key(dco_context_t *dco, unsigned int peerid, dco_key_slot_t slot) { -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1221?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: I612bf3b1c56d70a89fc04fad6fe36fd9fadfd258 Gerrit-Change-Number: 1221 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-MessageType: newchange --CiFh8bj5i0A= 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

dco_win: In dco_new_key, document size assumptions for the i=
nteger casts

And make all casts explicit so that compiler doesn'= t complain.

Change-Id: I612bf3b1c56d70a89fc04fad6fe36fd9fadfd258
= Signed-off-by: Frank Lichtenheld <frank@...2641...>
---
M src/o= penvpn/dco_win.c
1 file changed, 5 insertions(+), 12 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/21/1221/1<=
/pre>
-#if defined(__GN=
UC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"<= br>-#endif
-
int
dco_= new_key(dco_context_t *dco, unsigned int peerid, int keyid, dco_key_slot_t = slot,
const uint8_t *encrypt_key, const uint8_= t *encrypt_iv, const uint8_t *decrypt_key,
@@ -540,21 +535,= 23 @@

const int nonce_len =3D 8;
size_t key_len =3D cipher_kt_key_size(ciphername);=
+ ASSERT(key_len <=3D= 32);

OVPN_CRYPTO_DATA crypto_data;<= /span>
ZeroMemory(&crypto_data, sizeof(crypto_data));

crypto_data.CipherAlg =3D dco_get_ciphe= r(ciphername);
- cry= pto_data.KeyId =3D keyid;
+ ASSERT(keyid > 0 && keyid <=3D UCHAR_MAX);+ crypto_data.KeyId =3D (u= nsigned char)keyid;
crypto_data.PeerId =3D peerid;
crypto_data.KeySlot =3D slot;
CopyMemory(crypto_data.Encrypt.Key, encrypt_key, key_len);
- crypto_data.Encrypt.Ke= yLen =3D (char)key_len;
+ crypto_data.Encrypt.KeyLen =3D (unsigned char)key_len;
CopyMemory(crypto_data.Encrypt.NonceTail, encrypt_iv, nonce_len);<= /span>

CopyMemory(crypto_data.Decrypt.Key, = decrypt_key, key_len);
= - crypto_data.Decrypt.KeyLen =3D (char)key_len;
+ crypto_data.Decrypt.KeyLen =3D (unsigned= char)key_len;
CopyMemory(crypto_data.Decrypt.NonceTai= l, decrypt_iv, nonce_len);

ASSERT(cr= ypto_data.CipherAlg > 0);
@@ -570,10 +567,6 @@ return 0;
}

-#if defined(__GNUC__) || defined(__cla= ng__)
-#pragma GCC diag= nostic pop
-#endif
-
int
dco_del_key(dco_context_t *dco, unsigned int peerid, dco_key_s= lot_t slot)
{

To view,= visit c= hange 1221. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I612bf3b1c56d70a89fc04fad6fe= 36fd9fadfd258
Gerrit-Change-Number: 1221
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
--CiFh8bj5i0A=--