From: Frank Lichtenheld Date: Sun, 16 Nov 2025 18:33:30 +0000 (+0100) Subject: ssl: Fix conversion warning in tls_prepend_opcode_v1 X-Git-Tag: v2.7_rc2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d926257bf4636ea43f6f5c25f5235baa25f65203;p=thirdparty%2Fopenvpn.git ssl: Fix conversion warning in tls_prepend_opcode_v1 Document assumption with ASSERT. Change-Id: I34584f695ddca3b3e1f2bbcb4380ac91b09c1c8d Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1298 Message-Id: <20251116183336.11447-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34480.html Signed-off-by: Gert Doering --- diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c index 896fd651e..2d24f5e2e 100644 --- a/src/openvpn/ssl.c +++ b/src/openvpn/ssl.c @@ -3962,24 +3962,24 @@ tls_pre_encrypt(struct tls_multi *multi, struct buffer *buf, struct crypto_optio } } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + void tls_prepend_opcode_v1(const struct tls_multi *multi, struct buffer *buf) { struct key_state *ks = multi->save_ks; - uint8_t op; msg(D_TLS_DEBUG, __func__); ASSERT(ks); + ASSERT(ks->key_id <= P_KEY_ID_MASK); - op = (P_DATA_V1 << P_OPCODE_SHIFT) | ks->key_id; + uint8_t op = (P_DATA_V1 << P_OPCODE_SHIFT) | (uint8_t)ks->key_id; ASSERT(buf_write_prepend(buf, &op, 1)); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - void tls_prepend_opcode_v2(const struct tls_multi *multi, struct buffer *buf) {