Closed szszszsz closed 1 year ago
The maximum length for messages handled by usbd-ctaphid
is MESSAGE_SIZE = 3072
while ctaphid-dispatch
allows up to 7609 bytes. Pipe::handle_response
fails to ensure that the response returned by the application respects this limit. It should return ERR_OTHER
instead.
This PR avoids the panic and returns an error instead: https://github.com/trussed-dev/usbd-ctaphid/pull/2
usbd-ctaphid
crate crashes while handling big message.Found while executing load tests for oath-app over usb-ip simulation:
Note: check first, if the affected dependency is not outdated.
log
```rust thread 'main' panicked at 'range end index 7542 out of range for slice of length 3072', /home/sz/work/webcrypt/webcrypt -usbip/components/usbd-ctaphid/src/pipe.rs:570:25 stack backtrace: 0: rust_begin_unwind at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:584:5 1: core::panicking::panic_fmt at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/panicking.rs:142:14 2: core::slice::index::slice_end_index_len_fail_rt at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/slice/index.rs:76:5 3: core::slice::index::slice_end_index_len_fail at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/slice/index.rs:69:9 4:Edit: note: limiting reply's length avoids sim crash