mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
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>
This commit is contained in:
parent
ba57f8302a
commit
afa8680908
12 changed files with 124 additions and 53 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue