aboutsummaryrefslogtreecommitdiffstats
path: root/g10/keyring.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/keyring.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/keyring.c')
-rw-r--r--g10/keyring.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/g10/keyring.c b/g10/keyring.c
index e4fc111ed..2210df9c0 100644
--- a/g10/keyring.c
+++ b/g10/keyring.c
@@ -415,7 +415,7 @@ keyring_get_keyblock (KEYRING_HANDLE hd, KBNODE *ret_kb)
while ((rc=parse_packet (&parsectx, pkt)) != -1) {
hd->found.n_packets++;
if (gpg_err_code (rc) == GPG_ERR_UNKNOWN_PACKET) {
- free_packet (pkt);
+ free_packet (pkt, &parsectx);
init_packet (pkt);
continue;
}
@@ -461,7 +461,7 @@ keyring_get_keyblock (KEYRING_HANDLE hd, KBNODE *ret_kb)
default:
log_error ("skipped packet of type %d in keyring\n",
(int)pkt->pkttype);
- free_packet(pkt);
+ free_packet(pkt, &parsectx);
init_packet(pkt);
continue;
}
@@ -490,7 +490,7 @@ keyring_get_keyblock (KEYRING_HANDLE hd, KBNODE *ret_kb)
/* Reset LASTNODE, so that we set the cache status only from
* the ring trust packet immediately following a signature. */
lastnode = NULL;
- free_packet(pkt);
+ free_packet(pkt, &parsectx);
init_packet(pkt);
continue;
}
@@ -542,7 +542,8 @@ keyring_get_keyblock (KEYRING_HANDLE hd, KBNODE *ret_kb)
}
*ret_kb = keyblock;
}
- free_packet (pkt);
+ free_packet (pkt, &parsectx);
+ deinit_parse_packet (&parsectx);
xfree (pkt);
iobuf_close(a);
@@ -1132,7 +1133,7 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc,
rc = search_packet (&parsectx, &pkt, &offset, need_uid);
if (ignore_legacy && gpg_err_code (rc) == GPG_ERR_LEGACY_KEY)
{
- free_packet (&pkt);
+ free_packet (&pkt, &parsectx);
continue;
}
if (rc)
@@ -1146,7 +1147,7 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc,
}
if (initial_skip)
{
- free_packet (&pkt);
+ free_packet (&pkt, &parsectx);
continue;
}
@@ -1228,7 +1229,7 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc,
goto found;
}
}
- free_packet (&pkt);
+ free_packet (&pkt, &parsectx);
continue;
found:
if (rc)
@@ -1255,7 +1256,7 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc,
}
if (n == ndesc)
goto real_found;
- free_packet (&pkt);
+ free_packet (&pkt, &parsectx);
}
real_found:
if (!rc)
@@ -1309,7 +1310,8 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc,
hd->current.error = rc;
}
- free_packet(&pkt);
+ free_packet (&pkt, &parsectx);
+ deinit_parse_packet (&parsectx);
set_packet_list_mode(save_mode);
return rc;
}