From a966c2ce90802f2fa953b04e69fdc529d61b6f53 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 26 Sep 2025 16:27:13 +0200 Subject: gpg: Revamp structure of PKT_symkey_enc. * g10/packet.h (PKT_symkey_enc): Allocate the session key so that we have a fixed length for this struct. * g10/free-packet.c (free_symkey_enc): Adjust for this change * g10/parse-packet.c (parse_symkeyenc): Ditto. * g10/encrypt.c (encrypt_simple, write_symkey_enc): Ditto. --- g10/parse-packet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'g10/parse-packet.c') diff --git a/g10/parse-packet.c b/g10/parse-packet.c index ac784b7fb..32ec46b6f 100644 --- a/g10/parse-packet.c +++ b/g10/parse-packet.c @@ -1376,8 +1376,7 @@ parse_symkeyenc (IOBUF inp, int pkttype, unsigned long pktlen, goto leave; } seskeylen = pktlen - minlen; - k = packet->pkt.symkey_enc = xmalloc_clear (sizeof *packet->pkt.symkey_enc - + seskeylen - 1); + k = packet->pkt.symkey_enc = xmalloc_clear (sizeof *packet->pkt.symkey_enc); k->version = version; k->cipher_algo = cipher_algo; k->aead_algo = aead_algo; @@ -1396,6 +1395,7 @@ parse_symkeyenc (IOBUF inp, int pkttype, unsigned long pktlen, k->seskeylen = seskeylen; if (k->seskeylen) { + k->seskey = xcalloc (1, seskeylen); for (i = 0; i < seskeylen && pktlen; i++, pktlen--) k->seskey[i] = iobuf_get_noeof (inp); -- cgit