mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-26 01:18:28 +00:00
apps.fido_u2f: return correct cid on chan cancellation
This commit is contained in:
parent
2f40fa5363
commit
a1d3eda2ca
@ -181,7 +181,6 @@ def read_cmd(iface: int) -> Cmd:
|
|||||||
log.debug(__name__, 'read init %s', buf)
|
log.debug(__name__, 'read init %s', buf)
|
||||||
|
|
||||||
ifrm = overlay_struct(buf, desc_init)
|
ifrm = overlay_struct(buf, desc_init)
|
||||||
cid = ifrm.cid
|
|
||||||
bcnt = ifrm.bcnt
|
bcnt = ifrm.bcnt
|
||||||
data = ifrm.data
|
data = ifrm.data
|
||||||
datalen = len(data)
|
datalen = len(data)
|
||||||
@ -206,22 +205,28 @@ def read_cmd(iface: int) -> Cmd:
|
|||||||
cfrm = overlay_struct(buf, desc_cont)
|
cfrm = overlay_struct(buf, desc_cont)
|
||||||
|
|
||||||
if cfrm.seq == _CMD_INIT:
|
if cfrm.seq == _CMD_INIT:
|
||||||
|
# _CMD_INIT frame, cancels current channel
|
||||||
ifrm = overlay_struct(buf, desc_init)
|
ifrm = overlay_struct(buf, desc_init)
|
||||||
data = ifrm.data[:ifrm.bcnt]
|
data = ifrm.data[:ifrm.bcnt]
|
||||||
break
|
break
|
||||||
|
|
||||||
if cfrm.cid != cid:
|
if cfrm.cid != ifrm.cid:
|
||||||
|
# cont frame for a different channel, reply with BUSY and skip
|
||||||
|
log.warning(__name__, '_ERR_CHANNEL_BUSY')
|
||||||
send_cmd(cmd_error(cfrm.cid, _ERR_CHANNEL_BUSY), iface)
|
send_cmd(cmd_error(cfrm.cid, _ERR_CHANNEL_BUSY), iface)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if cfrm.seq != seq:
|
if cfrm.seq != seq:
|
||||||
|
# cont frame for this channel, but incorrect seq number, abort
|
||||||
|
# current msg
|
||||||
|
log.warning(__name__, '_ERR_INVALID_SEQ')
|
||||||
send_cmd(cmd_error(cfrm.cid, _ERR_INVALID_SEQ), iface)
|
send_cmd(cmd_error(cfrm.cid, _ERR_INVALID_SEQ), iface)
|
||||||
raise Exception(_ERR_INVALID_SEQ)
|
return None
|
||||||
|
|
||||||
datalen += utils.memcpy(data, datalen, cfrm.data, 0, bcnt - datalen)
|
datalen += utils.memcpy(data, datalen, cfrm.data, 0, bcnt - datalen)
|
||||||
seq += 1
|
seq += 1
|
||||||
|
|
||||||
return Cmd(cid, ifrm.cmd, data)
|
return Cmd(ifrm.cid, ifrm.cmd, data)
|
||||||
|
|
||||||
|
|
||||||
def send_cmd(cmd: Cmd, iface: int):
|
def send_cmd(cmd: Cmd, iface: int):
|
||||||
|
Loading…
Reference in New Issue
Block a user