summaryrefslogtreecommitdiffstats
path: root/scd/app-openpgp.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2020-09-04 10:16:59 +0200
committerNIIBE Yutaka <gniibe@fsij.org>2020-09-04 10:16:59 +0200
commit43bbc25b0f57dec24412886ff46041e0b1f3de26 (patch)
tree0d78d2ebe4d51f732cb4836f388fd1993d6da084 /scd/app-openpgp.c
parentscd: Parse "Algorithm Information" data object in scdaemon. (diff)
downloadgnupg2-43bbc25b0f57dec24412886ff46041e0b1f3de26.tar.xz
gnupg2-43bbc25b0f57dec24412886ff46041e0b1f3de26.zip
scd: Support GET DATA response with no header for DO 0x00FA.
* scd/app-openpgp.c (do_getattr): Support Gnuk, as well. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to '')
-rw-r--r--scd/app-openpgp.c53
1 files changed, 28 insertions, 25 deletions
diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c
index 56a84bca5..f0c5449f8 100644
--- a/scd/app-openpgp.c
+++ b/scd/app-openpgp.c
@@ -1256,36 +1256,39 @@ do_getattr (app_t app, ctrl_t ctrl, const char *name)
if (valuelen < 2)
return gpg_error (GPG_ERR_INV_OBJ);
- tag = *p++;
- len = *p++;
+ tag = p[0];
+ len = p[1];
- if (tag != 0x00FA)
- return gpg_error (GPG_ERR_INV_OBJ);
-
- if (len == 0x81)
- {
- if (valuelen < 3)
- return gpg_error (GPG_ERR_INV_OBJ);
- len = *p++;
- }
- else if (len == 0x82)
+ /* Does it comes tag+len at the head? */
+ if (tag == 0x00FA)
{
- if (valuelen < 4)
- return gpg_error (GPG_ERR_INV_OBJ);
- len = *p++;
- len = (len << 8) | *p++;
- }
+ p += 2;
- valuelen -= (p - value);
- value = p;
+ if (len == 0x81)
+ {
+ if (valuelen < 3)
+ return gpg_error (GPG_ERR_INV_OBJ);
+ len = *p++;
+ }
+ else if (len == 0x82)
+ {
+ if (valuelen < 4)
+ return gpg_error (GPG_ERR_INV_OBJ);
+ len = *p++;
+ len = (len << 8) | *p++;
+ }
- if (valuelen != len)
- {
- if (opt.verbose)
- log_info ("Yubikey bug: length %zu != %zu", valuelen, len);
+ valuelen -= (p - value);
+ value = (unsigned char *)p;
- if (app->card->cardtype != CARDTYPE_YUBIKEY)
- return gpg_error (GPG_ERR_INV_OBJ);
+ if (valuelen != len)
+ {
+ if (opt.verbose)
+ log_info ("Yubikey bug: length %zu != %zu", valuelen, len);
+
+ if (app->card->cardtype != CARDTYPE_YUBIKEY)
+ return gpg_error (GPG_ERR_INV_OBJ);
+ }
}
for (; p < value + valuelen; p += len)