diff options
author | Werner Koch <wk@gnupg.org> | 2017-03-29 11:57:40 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2017-03-29 12:08:31 +0200 |
commit | afa86809087909a8ba2f9356588bf90cc923529c (patch) | |
tree | ff0941a7831c23a47f9dafa522b375b7cc00daa4 /g10/mainproc.c | |
parent | indent: Re-indent function free-packet. (diff) | |
download | gnupg2-afa86809087909a8ba2f9356588bf90cc923529c.tar.xz gnupg2-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 <wk@gnupg.org>
Diffstat (limited to 'g10/mainproc.c')
-rw-r--r-- | g10/mainproc.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/g10/mainproc.c b/g10/mainproc.c index 30d9b1812..8581104de 100644 --- a/g10/mainproc.c +++ b/g10/mainproc.c @@ -358,7 +358,7 @@ proc_symkey_enc (CTX c, PACKET *pkt) leave: c->symkeys++; - free_packet (pkt); + free_packet (pkt, NULL); } @@ -456,7 +456,7 @@ proc_pubkey_enc (ctrl_t ctrl, CTX c, PACKET *pkt) log_info (_("public key encrypted data: good DEK\n")); } - free_packet(pkt); + free_packet(pkt, NULL); } @@ -657,7 +657,7 @@ proc_encrypted (CTX c, PACKET *pkt) xfree (c->dek); c->dek = NULL; - free_packet (pkt); + free_packet (pkt, NULL); c->last_was_session_key = 0; write_status (STATUS_END_DECRYPTION); } @@ -774,7 +774,7 @@ proc_plaintext( CTX c, PACKET *pkt ) if (rc) log_error ("handle plaintext failed: %s\n", gpg_strerror (rc)); - free_packet(pkt); + free_packet (pkt, NULL); c->last_was_session_key = 0; /* We add a marker control packet instead of the plaintext packet. @@ -837,7 +837,7 @@ proc_compressed (CTX c, PACKET *pkt) else if (rc) log_error ("uncompressing failed: %s\n", gpg_strerror (rc)); - free_packet(pkt); + free_packet (pkt, NULL); c->last_was_session_key = 0; return rc; } @@ -1348,7 +1348,7 @@ do_proc_packets (ctrl_t ctrl, CTX c, iobuf_t a) any_data = 1; if (rc) { - free_packet (pkt); + free_packet (pkt, &parsectx); /* Stop processing when an invalid packet has been encountered * but don't do so when we are doing a --list-packets. */ if (gpg_err_code (rc) == GPG_ERR_INV_PACKET @@ -1466,7 +1466,7 @@ do_proc_packets (ctrl_t ctrl, CTX c, iobuf_t a) init_packet (pkt); } else - free_packet(pkt); + free_packet (pkt, &parsectx); } if (rc == GPG_ERR_INV_PACKET) @@ -1481,7 +1481,8 @@ do_proc_packets (ctrl_t ctrl, CTX c, iobuf_t a) leave: release_list (c); xfree(c->dek); - free_packet (pkt); + free_packet (pkt, &parsectx); + deinit_parse_packet (&parsectx); xfree (pkt); free_md_filter_context (&c->mfx); return rc; |