1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +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>
This commit is contained in:
Werner Koch 2024-05-28 16:44:18 +02:00
parent fdc5003956
commit bdbf5cee2f
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -196,6 +196,7 @@ handle_pincache_get (const char *args, assuan_context_t ctx)
const char *key;
char *pin = NULL;
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. */
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: