From: "flichtenheld (Code Review)" Date: Mon, 13 Jan 2025 10:44:19 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <045ab59d11284a222e6ce5681d20fa7cb52ae84b-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="IJvbQXbumEQ="; 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: plaisthos Cc: openvpn-devel --IJvbQXbumEQ= 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/+/858?usp=3Demail to review the following change. 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 --- M src/openvpn/crypto.c 1 file changed, 5 insertions(+), 5 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/58/858/1 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: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-MessageType: newchange --IJvbQXbumEQ= 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.

Vi= ew Change

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 m= ove the declaration of outlen to the first
usage.

Change-Id: I039= 1f30a1e962ee242e9bcdec4f605bf7e831cca
Signed-off-by: Frank Lichtenheld &= lt;frank@...2641...>
---
M src/openvpn/crypto.c
1 file changed,= 5 insertions(+), 5 deletions(-)

git pull ssh://gerrit.openvpn.ne=
t:29418/openvpn refs/changes/58/858/1
diff --git a/src/openvpn/cryp=
to.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 ke= y_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 r= eached.");
}

- int outlen;
- struct gc_arena gc;
-
- gc_init(&gc);
-
ASSERT(opt);
ASSERT(f= rame);
ASSERT(buf->len > 0);
@@ = -506,6 +504,8 @@
dmsg(D_PACKET_CONTENT, "DECRYPT = AD: %s",
format_hex(ad_start, ad_size, 0, &a= mp;gc));

+ int outlen;
change 858. 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: 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
--IJvbQXbumEQ=--