1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-06 23:17:47 +02:00

scd: Fix handling for Data Object with no data.

* scd/app-openpgp.c (get_cached_data): Return NULL for Data Object
with no data.

--

When GET_DATA returns no data with success (90 00), this routine
firstly returned buffer with length zero, and secondly (with cache)
returned NULL, which is inconsistent.  Now, it returns NULL for both
cases.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2018-02-12 18:56:58 +09:00
parent e0658b19d9
commit 0a3bec2c25

View File

@ -348,7 +348,8 @@ get_cached_data (app_t app, int tag,
err = iso7816_get_data (app->slot, exmode, tag, &p, &len); err = iso7816_get_data (app->slot, exmode, tag, &p, &len);
if (err) if (err)
return err; return err;
*result = p; if (len)
*result = p;
*resultlen = len; *resultlen = len;
/* Check whether we should cache this object. */ /* Check whether we should cache this object. */
@ -370,7 +371,10 @@ get_cached_data (app_t app, int tag,
c = xtrymalloc (sizeof *c + len); c = xtrymalloc (sizeof *c + len);
if (c) if (c)
{ {
memcpy (c->data, p, len); if (len)
memcpy (c->data, p, len);
else
xfree (p);
c->length = len; c->length = len;
c->tag = tag; c->tag = tag;
c->next = app->app_local->cache; c->next = app->app_local->cache;