Skip to content

Commit e46f830

Browse files
sportron-ledgeryogh333
authored andcommitted
[io] fix some issues
1 parent 063cf2b commit e46f830

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
}
@@ -443,7 +443,7 @@ impl Comm {
443443
}
444444
self.apdu_type = packet_type;
445445
self.rx_length = length as usize;
446-
self.rx = self.rx_length;
446+
self.rx = self.rx_length-1;
447447
self.event_pending = true;
448448
return self.check_event();
449449
}
@@ -462,7 +462,7 @@ impl Comm {
462462
match self.decode_event::<T>(length) {
463463
Some(Event::Command(_)) => {
464464
self.rx_length = length as usize;
465-
self.rx = self.rx_length;
465+
self.rx = self.rx_length-1;
466466
self.event_pending = true;
467467
return true;
468468
}
@@ -560,7 +560,7 @@ impl Comm {
560560
}
561561

562562
pub fn get_data(&self) -> Result<&[u8], StatusWords> {
563-
if self.rx_length == 6 {
563+
if self.rx_length == 5 {
564564
Ok(&[]) // Conforming zero-data APDU
565565
} else {
566566
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)