From: "cron2 (Code Review)" Date: Mon, 13 Jan 2025 11:43:31 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., a@...2181... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="M49KLgwjwQc="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Fix 'uninitialized pointer read' in openvpn_decrypt_aead List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: plaisthos , openvpn-devel --M49KLgwjwQc= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/85= 8?usp=3Demail ) Change subject: Fix 'uninitialized pointer read' in openvpn_decrypt_aead ...................................................................... Fix 'uninitialized pointer read' in openvpn_decrypt_aead Coverity complains that if we error out in the first error condition we try to free gc without initializing it. While here move the declaration of outlen to the first usage. Change-Id: I0391f30a1e962ee242e9bcdec4f605bf7e831cca Signed-off-by: Frank Lichtenheld Acked-by: Antonio Quartulli Message-Id: <20250113112226.17728-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30= 421.html Signed-off-by: Gert Doering --- M src/openvpn/crypto.c 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c index 84ec436..dbd95a8 100644 --- a/src/openvpn/crypto.c +++ b/src/openvpn/crypto.c @@ -406,17 +406,15 @@ static const char error_prefix[] =3D "AEAD Decrypt error"; struct packet_id_net pin =3D { 0 }; struct key_ctx *ctx =3D &opt->key_ctx_bi.decrypt; + struct gc_arena gc; + + gc_init(&gc); if (cipher_decrypt_verify_fail_exceeded(ctx)) { CRYPT_DROP("Decryption failed verification limit reached."); } - int outlen; - struct gc_arena gc; - - gc_init(&gc); - ASSERT(opt); ASSERT(frame); ASSERT(buf->len > 0); @@ -506,6 +504,8 @@ dmsg(D_PACKET_CONTENT, "DECRYPT AD: %s", format_hex(ad_start, ad_size, 0, &gc)); + int outlen; + /* Decrypt and authenticate packet */ if (!cipher_ctx_update(ctx->cipher, BPTR(&work), &outlen, BPTR(buf), data_len)) -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/858?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: I0391f30a1e962ee242e9bcdec4f605bf7e831cca Gerrit-Change-Number: 858 Gerrit-PatchSet: 2 Gerrit-Owner: flichtenheld Gerrit-Reviewer: ordex Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: merged --M49KLgwjwQc= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 submitted this change.

View Change

Fix 'uninitialized pointer read' in op=
envpn_decrypt_aead

Coverity complains that if we error out in the fi= rst
error condition we try to free gc without initializing
it.
While here move the declaration of outlen to the first
usage.

Ch= ange-Id: I0391f30a1e962ee242e9bcdec4f605bf7e831cca
Signed-off-by: Frank = Lichtenheld <frank@...2641...>
Acked-by: Antonio Quartulli <a@...220...= ..2181...>
Message-Id: <20250113112226.17728-1-gert@...1296...>=
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/m= sg30421.html
Signed-off-by: Gert Doering <gert@...1296...>
---<= br>M src/openvpn/crypto.c
1 file changed, 5 insertions(+), 5 deletions(-= )

diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c
index 84ec436..dbd95a8 100644
--- a/src/openvpn/crypto.c
+++ b/src/openvpn/crypto.c
@@ -406,17 +406,1= 5 @@
static const char error_prefix[] =3D "AEAD D= ecrypt error";
struct packet_id_net pin =3D { 0 }= ;
struct key_ctx *ctx =3D &opt->key_ctx_bi.decr= ypt;
+ struct gc_a= rena gc;
+
= + gc_init(&gc);
if (cipher_decrypt_verify_fail_exceeded(ctx)= )
{
CRYPT_DROP("Decrypti= on failed verification limit reached.");
}=

- int ou= tlen;
- struct gc_ar= ena gc;
-
- gc_init(&gc);

-
ASSERT(opt);<= /span>
ASSERT(frame);
ASSERT(buf->len= > 0);
@@ -506,6 +504,8 @@
dmsg(D_P= ACKET_CONTENT, "DECRYPT AD: %s",
format= _hex(ad_start, ad_size, 0, &gc));

+ int outlen;
+
/* Decrypt and auth= enticate packet */
if (!cipher_ctx_update(ctx->ciph= er, BPTR(&work), &outlen, BPTR(buf),
= data_len))

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I0391f30a1e962ee242e9bcdec4f= 605bf7e831cca
Gerrit-Change-Number: 858
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: ordex <a@...2181...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: merged
--M49KLgwjwQc=--