From 7bf24e8146116a30c4c9d7b6dbf8bbb27fc35971 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 30 Mar 2017 16:01:52 +0200 Subject: gpg: Fix actual leak and possible leaks in the packet parser. * g10/packet.h (struct parse_packet_ctx_s): Change LAST_PKT deom a pointer to its struct. (init_parse_packet): Adjust for LAST_PKT not being a pointer. * g10/parse-packet.c (parse): Ditto. Free the last packet before storing a new one in case of a deep link. (parse_ring_trust): Adjust for LAST_PKT not being a pointer. * g10/free-packet.c (free_packet): Ditto. * g10/t-keydb-get-keyblock.c (do_test): Release keyblock. -- Fixes-commit: afa86809087909a8ba2f9356588bf90cc923529c Signed-off-by: Werner Koch --- g10/packet.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'g10/packet.h') diff --git a/g10/packet.h b/g10/packet.h index b23298aac..f5f22b695 100644 --- a/g10/packet.h +++ b/g10/packet.h @@ -621,7 +621,7 @@ int set_packet_list_mode( int mode ); struct parse_packet_ctx_s { iobuf_t inp; /* The input stream with the packets. */ - PACKET *last_pkt; /* The last parsed packet. */ + struct packet_struct last_pkt; /* The last parsed packet. */ int free_last_pkt; /* Indicates that LAST_PKT must be freed. */ int skip_meta; /* Skip right trust packets. */ }; @@ -629,7 +629,8 @@ typedef struct parse_packet_ctx_s *parse_packet_ctx_t; #define init_parse_packet(a,i) do { \ (a)->inp = (i); \ - (a)->last_pkt = NULL; \ + (a)->last_pkt.pkttype = 0; \ + (a)->last_pkt.pkt.generic= NULL;\ (a)->free_last_pkt = 0; \ (a)->skip_meta = 0; \ } while (0) -- cgit v1.2.3