aboutsummaryrefslogtreecommitdiffstats
path: root/g10/import.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2017-03-29 09:57:40 +0000
committerWerner Koch <[email protected]>2017-03-29 10:08:31 +0000
commitafa86809087909a8ba2f9356588bf90cc923529c (patch)
treeff0941a7831c23a47f9dafa522b375b7cc00daa4 /g10/import.c
parentindent: Re-indent function free-packet. (diff)
downloadgnupg-afa86809087909a8ba2f9356588bf90cc923529c.tar.gz
gnupg-afa86809087909a8ba2f9356588bf90cc923529c.zip
gpg: Extend free_packet to handle a packet parser context.
* g10/packet.h (struct parse_packet_ctx_s): Add fields LAST_PKT and FREE_LAST_PKT. (init_parse_packet): Clear them. (deinit_parse_packet): New macro. Change all users if init_parse_packet to also call this macro. * g10/free-packet.c (free_packet): Add arg PARSECTX and handle shallow packet copies in the context. Change all callers. * g10/parse-packet.c (parse): Store certain packets in the parse context. -- Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/import.c')
-rw-r--r--g10/import.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/g10/import.c b/g10/import.c
index 9aa6c8b66..3321a7eb8 100644
--- a/g10/import.c
+++ b/g10/import.c
@@ -790,7 +790,7 @@ read_block( IOBUF a, PACKET **pending_pkt, kbnode_t *ret_root, int *r_v3keys)
{
in_v3key = 1;
++*r_v3keys;
- free_packet (pkt);
+ free_packet (pkt, &parsectx);
init_packet (pkt);
continue;
}
@@ -804,7 +804,7 @@ read_block( IOBUF a, PACKET **pending_pkt, kbnode_t *ret_root, int *r_v3keys)
rc = GPG_ERR_INV_KEYRING;
goto ready;
}
- free_packet( pkt );
+ free_packet (pkt, &parsectx);
init_packet(pkt);
continue;
}
@@ -812,7 +812,7 @@ read_block( IOBUF a, PACKET **pending_pkt, kbnode_t *ret_root, int *r_v3keys)
if (in_v3key && !(pkt->pkttype == PKT_PUBLIC_KEY
|| pkt->pkttype == PKT_SECRET_KEY))
{
- free_packet( pkt );
+ free_packet (pkt, &parsectx);
init_packet(pkt);
continue;
}
@@ -843,7 +843,7 @@ read_block( IOBUF a, PACKET **pending_pkt, kbnode_t *ret_root, int *r_v3keys)
pkt->pkt.compressed->buf = NULL;
push_compress_filter2(a,cfx,pkt->pkt.compressed->algorithm,1);
}
- free_packet( pkt );
+ free_packet (pkt, &parsectx);
init_packet(pkt);
break;
@@ -851,7 +851,7 @@ read_block( IOBUF a, PACKET **pending_pkt, kbnode_t *ret_root, int *r_v3keys)
/* Skip those packets unless we are in restore mode. */
if ((opt.import_options & IMPORT_RESTORE))
goto x_default;
- free_packet( pkt );
+ free_packet (pkt, &parsectx);
init_packet(pkt);
break;
@@ -887,7 +887,8 @@ read_block( IOBUF a, PACKET **pending_pkt, kbnode_t *ret_root, int *r_v3keys)
release_kbnode( root );
else
*ret_root = root;
- free_packet( pkt );
+ free_packet (pkt, &parsectx);
+ deinit_parse_packet (&parsectx);
xfree( pkt );
return rc;
}