1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 23:48:12 +00:00

apps.fido_u2f: fix data length, handle channel reset

This commit is contained in:
Jan Pochyla 2017-05-23 20:23:44 +02:00
parent fab5b9a98c
commit 9f352959ee

View File

@ -191,6 +191,8 @@ def read_cmd(iface: int) -> Cmd:
databuf = bytearray(bcnt) databuf = bytearray(bcnt)
utils.memcpy(databuf, 0, data, 0, bcnt) utils.memcpy(databuf, 0, data, 0, bcnt)
data = databuf data = databuf
else:
data = data[:bcnt]
while datalen < bcnt: while datalen < bcnt:
buf, = yield loop.select(iface) buf, = yield loop.select(iface)
@ -198,6 +200,11 @@ def read_cmd(iface: int) -> Cmd:
cfrm = overlay_struct(buf, desc_cont) 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: if cfrm.cid != cid:
send_cmd(cmd_error(cfrm.cid, _ERR_CHANNEL_BUSY), iface) send_cmd(cmd_error(cfrm.cid, _ERR_CHANNEL_BUSY), iface)
continue continue