diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2021-06-08 03:34:38 +0200 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2021-06-08 03:37:48 +0200 |
commit | c3a9ee0b658887ca9baa4514187b17857fdf6586 (patch) | |
tree | 0afbaf974c5dd82f8c7810c72b7efedbeb488339 /scd/app.c | |
parent | scd: Fix READER-PORT option handling for PC/SC. (diff) | |
download | gnupg2-c3a9ee0b658887ca9baa4514187b17857fdf6586.tar.xz gnupg2-c3a9ee0b658887ca9baa4514187b17857fdf6586.zip |
scd: Fix serial number detection for Yubikey 5.
* scd/app.c (app_new_register): Handle serial number correctly.
--
GnuPG-bug-id: 5442
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to '')
-rw-r--r-- | scd/app.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -532,17 +532,18 @@ app_new_register (int slot, ctrl_t ctrl, const char *name, formfactor = (s0 && n == 1)? *s0 : 0; s0 = find_tlv (buf+1, buflen-1, 0x02, &n); /* Serial */ - if (s0 && n >= 4) + if (s0 && n <= 4) { - card->serialno = xtrymalloc (3 + 1 + n); + card->serialno = xtrymalloc (3 + 1 + 4); if (card->serialno) { - card->serialnolen = 3 + 1 + n; + card->serialnolen = 3 + 1 + 4; card->serialno[0] = 0xff; card->serialno[1] = 0x02; card->serialno[2] = 0x0; card->serialno[3] = formfactor; - memcpy (card->serialno + 4, s0, n); + memset (card->serialno + 4, 0, 4 - n); + memcpy (card->serialno + 4 + 4 - n, s0, n); err = app_munge_serialno (card); } } |