diff options
author | Werner Koch <[email protected]> | 2021-06-10 10:43:40 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2021-06-10 10:44:23 +0000 |
commit | c2f02797cdefdce5afd8b29bb8e51d4515a70a96 (patch) | |
tree | 8da40d9d50abc5042eef611676a457724953c37f | |
parent | speedo,w32: Remove a leftover directory during uninstall (diff) | |
download | gnupg-c2f02797cdefdce5afd8b29bb8e51d4515a70a96.tar.gz gnupg-c2f02797cdefdce5afd8b29bb8e51d4515a70a96.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 <[email protected]>
Backported-from-master: c3a9ee0b658887ca9baa4514187b17857fdf6586
-rw-r--r-- | scd/app.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -299,17 +299,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) { - app->serialno = xtrymalloc (3 + 1 + n); + app->serialno = xtrymalloc (3 + 1 + 4); if (app->serialno) { - app->serialnolen = 3 + 1 + n; + app->serialnolen = 3 + 1 + 4; app->serialno[0] = 0xff; app->serialno[1] = 0x02; app->serialno[2] = 0x0; app->serialno[3] = formfactor; - memcpy (app->serialno + 4, s0, n); + memset (app->serialno + 4, 0, 4 - n); + memcpy (app->serialno + 4 + 4 - n, s0, n); err = app_munge_serialno (app); } } |