1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-11-10 21:38:50 +01:00

agent: Avoid double free of empty string in the PIN caching.

* agent/call-scd.c (handle_pincache_get): Set PIN to NULL.  Also add
DBG_CACHE conditionals and don't return the pin in the debug output.
--

This is part of
GnuPG-bug-id: 7129
Co-authored-by: Jakub Jelen <jjelen@redhat.com>

(cherry picked from commit bdbf5cee2f)
This commit is contained in:
Werner Koch 2024-05-28 16:44:18 +02:00
parent 19d93a239d
commit 5e7ea64305
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -196,7 +196,8 @@ handle_pincache_get (const char *args, assuan_context_t ctx)
const char *key;
char *pin = NULL;
log_debug ("%s: enter '%s'\n", __func__, args);
if (DBG_CACHE)
log_debug ("%s: enter '%s'\n", __func__, args);
key = args;
if (strlen (key) < 5)
{
@ -210,11 +211,14 @@ handle_pincache_get (const char *args, assuan_context_t ctx)
if (!pin || !*pin)
{
xfree (pin);
pin = NULL;
err = 0; /* Not found is indicated by sending no data back. */
log_debug ("%s: not cached\n", __func__);
if (DBG_CACHE)
log_debug ("%s: not cached\n", __func__);
goto leave;
}
log_debug ("%s: cache returned '%s'\n", __func__, pin);
if (DBG_CACHE)
log_debug ("%s: cache returned '%s'\n", __func__, "[hidden]"/*pin*/);
err = assuan_send_data (ctx, pin, strlen (pin));
leave: