Skip to content

Commit e76625f

Browse files
[io] fix some issues
1 parent 678177d commit e76625f

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

ledger_device_sdk/src/io.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ impl Comm {
267267
self.event_pending = false;
268268

269269
// Reject incomplete APDUs
270-
if self.rx_length < 6 {
270+
if self.rx_length < 5 {
271271
self.reply(StatusWords::BadLen);
272272
return None;
273273
}
@@ -439,7 +439,7 @@ impl Comm {
439439
}
440440
self.apdu_type = packet_type;
441441
self.rx_length = length as usize;
442-
self.rx = self.rx_length;
442+
self.rx = self.rx_length-1;
443443
self.event_pending = true;
444444
return self.check_event();
445445
}
@@ -458,7 +458,7 @@ impl Comm {
458458
match self.decode_event::<T>(length) {
459459
Some(Event::Command(_)) => {
460460
self.rx_length = length as usize;
461-
self.rx = self.rx_length;
461+
self.rx = self.rx_length-1;
462462
self.event_pending = true;
463463
return true;
464464
}
@@ -556,7 +556,7 @@ impl Comm {
556556
}
557557

558558
pub fn get_data(&self) -> Result<&[u8], StatusWords> {
559-
if self.rx_length == 6 {
559+
if self.rx_length == 5 {
560560
Ok(&[]) // Conforming zero-data APDU
561561
} else {
562562
let first_len_byte = self.io_buffer[5] as usize;

ledger_device_sdk/src/uxapp.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub enum UxEvent {
2727

2828
impl UxEvent {
2929
#[allow(unused)]
30-
pub fn request(&self, comm: &mut Comm) -> u32 {
30+
pub fn request(&self) -> u32 {
3131
unsafe {
3232
//let mut params = bolos_ux_params_t::default();
3333
G_ux_params.ux_id = match self {
@@ -55,20 +55,21 @@ impl UxEvent {
5555
os_ux(&raw mut G_ux_params as *mut bolos_ux_params_t);
5656

5757
match self {
58-
Self::ValidatePIN => Self::block(comm),
58+
Self::ValidatePIN => Self::block(),
5959
_ => os_sched_last_status(TASK_BOLOS_UX as u32) as u32,
6060
}
6161
}
6262
}
6363

64-
pub fn block(comm: &mut Comm) -> u32 {
64+
pub fn block() -> u32 {
6565
let mut ret = unsafe { os_sched_last_status(TASK_BOLOS_UX as u32) } as u32;
6666
while ret == BOLOS_UX_IGNORE || ret == BOLOS_UX_CONTINUE {
6767
if unsafe { os_sched_is_running(TASK_SUBTASKS_START as u32) }
6868
!= BOLOS_TRUE.try_into().unwrap()
6969
{
70-
sys_seph::io_rx(&mut comm.io_buffer, true);
71-
UxEvent::Event.request(comm);
70+
let mut spi_buffer = [0u8; 256];
71+
sys_seph::io_rx(&mut spi_buffer, true);
72+
UxEvent::Event.request();
7273
} else {
7374
unsafe { os_sched_yield(BOLOS_UX_OK as u8) };
7475
}
@@ -93,7 +94,7 @@ impl UxEvent {
9394
event = comm.decode_event(status)
9495
}
9596

96-
UxEvent::Event.request(comm);
97+
UxEvent::Event.request();
9798

9899
if let Option::Some(Event::Command(_)) = event {
99100
return (ret, event);

0 commit comments

Comments
 (0)