Skip to content

Commit 866e41a

Browse files
authored
Merge pull request #79 from siketyan/feat/upgrade-apdu-rs
fix: Fix PC/SC handler is not writing responses
2 parents 52371d3 + 1a85f2a commit 866e41a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

core/src/pcsc.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
//! ```
3131
3232
use std::ffi::{CStr, CString};
33+
use std::io::Write;
3334
use std::marker::PhantomData;
3435
use std::thread::sleep;
3536
use std::time::Duration;
@@ -171,7 +172,7 @@ impl<'a> HandlerInCtx<Ctx> for PcscCard<'a> {
171172
&self,
172173
_: Ctx,
173174
command: &[u8],
174-
response: &mut [u8],
175+
mut response: &mut [u8],
175176
) -> std::result::Result<usize, HandleError> {
176177
let tx = Vec::from(command);
177178
let rx = self.transmit(&tx).unwrap();
@@ -180,6 +181,9 @@ impl<'a> HandlerInCtx<Ctx> for PcscCard<'a> {
180181
return Err(HandleError::NotEnoughBuffer(len));
181182
}
182183

183-
Ok(len)
184+
match response.write(&rx) {
185+
Ok(size) => Ok(size),
186+
Err(e) => Err(HandleError::Nfc(Box::new(e))),
187+
}
184188
}
185189
}

0 commit comments

Comments
 (0)