From 9f352959ee0fa2117b734e082a919de351e20933 Mon Sep 17 00:00:00 2001 From: Jan Pochyla Date: Tue, 23 May 2017 20:23:44 +0200 Subject: [PATCH] apps.fido_u2f: fix data length, handle channel reset --- src/apps/fido_u2f/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/apps/fido_u2f/__init__.py b/src/apps/fido_u2f/__init__.py index e2e1d6a4c2..e4e3048107 100644 --- a/src/apps/fido_u2f/__init__.py +++ b/src/apps/fido_u2f/__init__.py @@ -191,6 +191,8 @@ def read_cmd(iface: int) -> Cmd: databuf = bytearray(bcnt) utils.memcpy(databuf, 0, data, 0, bcnt) data = databuf + else: + data = data[:bcnt] while datalen < bcnt: buf, = yield loop.select(iface) @@ -198,6 +200,11 @@ def read_cmd(iface: int) -> Cmd: cfrm = overlay_struct(buf, desc_cont) + if cfrm.seq == _CMD_INIT: + ifrm = overlay_struct(buf, desc_init) + data = ifrm.data[:ifrm.bcnt] + break + if cfrm.cid != cid: send_cmd(cmd_error(cfrm.cid, _ERR_CHANNEL_BUSY), iface) continue