mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
apps.fido_u2f: fix data length, handle channel reset
This commit is contained in:
parent
fab5b9a98c
commit
9f352959ee
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user