Skip to content

Commit

Permalink
Fix 'uninitialized pointer read' in openvpn_decrypt_aead
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Antonio Quartulli <[email protected]>
Message-Id: <[email protected]>
URL: https://www.mail-archive.com/[email protected]/msg30421.html
Signed-off-by: Gert Doering <[email protected]>
  • Loading branch information
flichtenheld authored and cron2 committed Jan 13, 2025
1 parent 0671a4d commit 5e086c0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/openvpn/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,17 +406,15 @@ openvpn_decrypt_aead(struct buffer *buf, struct buffer work,
static const char error_prefix[] = "AEAD Decrypt error";
struct packet_id_net pin = { 0 };
struct key_ctx *ctx = &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);
Expand Down Expand Up @@ -506,6 +504,8 @@ openvpn_decrypt_aead(struct buffer *buf, struct buffer work,
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))
Expand Down

0 comments on commit 5e086c0

Please sign in to comment.