Fix offset calculation

This commit is contained in:
wackazong 2025-01-10 11:50:40 +01:00 committed by Dario Nieuwenhuis
parent d1429868ce
commit 9ac8944478

View File

@ -91,7 +91,7 @@ async fn main(_spawner: Spawner) {
}
(0, 0xb0, p1, p2) => {
info!("read");
let offs = u16::from_be_bytes([p1 & 0xef, p2]) as usize;
let offs = u16::from_be_bytes([p1 & 0x7f, p2]) as usize;
let len = if apdu.le == 0 { usize::MAX } else { apdu.le as usize };
let n = len.min(selected.len() - offs);
buf[..n].copy_from_slice(&selected[offs..][..n]);