aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2018-02-12 09:56:58 +0000
committerNIIBE Yutaka <[email protected]>2018-02-12 09:56:58 +0000
commit0a3bec2c2525935362f87dce93d7df2c8d498498 (patch)
treed04194bfb0a302cd83c91a61be34c5d9b349f19d
parentdoc: Add compliance de-vs to gpgsm in vsnfd.prf (diff)
downloadgnupg-0a3bec2c2525935362f87dce93d7df2c8d498498.tar.gz
gnupg-0a3bec2c2525935362f87dce93d7df2c8d498498.zip
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 <[email protected]>
-rw-r--r--scd/app-openpgp.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c
index c9f2840e6..5b1b0d339 100644
--- a/scd/app-openpgp.c
+++ b/scd/app-openpgp.c
@@ -348,7 +348,8 @@ get_cached_data (app_t app, int tag,
err = iso7816_get_data (app->slot, exmode, tag, &p, &len);
if (err)
return err;
- *result = p;
+ if (len)
+ *result = p;
*resultlen = len;
/* Check whether we should cache this object. */
@@ -370,7 +371,10 @@ get_cached_data (app_t app, int tag,
c = xtrymalloc (sizeof *c + len);
if (c)
{
- memcpy (c->data, p, len);
+ if (len)
+ memcpy (c->data, p, len);
+ else
+ xfree (p);
c->length = len;
c->tag = tag;
c->next = app->app_local->cache;