Skip to content

Commit

Permalink
Merge pull request #36 from carl-wallace/develop
Browse files Browse the repository at this point in the history
Make anonymous CHUID struct public, remove spurious subtraction of two bytes in transfer_data
  • Loading branch information
tarcieri authored Nov 27, 2019
2 parents d799e9c + 13b350f commit 82b4bbb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/chuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const CHUID_TMPL: &[u8] = &[

/// Cardholder Unique Identifier (CHUID)
#[derive(Copy, Clone, Debug)]
pub struct CHUID([u8; YKPIV_CARDID_SIZE]);
pub struct CHUID(pub [u8; YKPIV_CARDID_SIZE]);

impl CHUID {
/// Generate a random Cardholder Unique Identifier (CHUID)
Expand Down
12 changes: 6 additions & 6 deletions src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,17 +421,17 @@ impl<'tx> Transaction<'tx> {

sw = response.status_words().code();

if out_data.len() - response.data().len() - 2 > max_out {
if !out_data.is_empty() && (out_data.len() - response.data().len() > max_out) {
error!(
"output buffer too small: wanted to write {}, max was {}",
out_data.len() - response.data().len() - 2,
out_data.len() - response.data().len(),
max_out
);

return Err(Error::SizeError);
}

out_data.extend_from_slice(&response.data()[..response.data().len() - 2]);
out_data.extend_from_slice(&response.data()[..response.data().len()]);

in_offset += this_size;
if in_offset >= in_data.len() {
Expand All @@ -452,17 +452,17 @@ impl<'tx> Transaction<'tx> {
return Ok(Response::new(sw.into(), vec![]));
}

if out_data.len() + response.data().len() - 2 > max_out {
if out_data.len() + response.data().len() > max_out {
error!(
"output buffer too small: wanted to write {}, max was {}",
out_data.len() + response.data().len() - 2,
out_data.len() + response.data().len(),
max_out
);

return Err(Error::SizeError);
}

out_data.extend_from_slice(&response.data()[..response.data().len() - 2]);
out_data.extend_from_slice(&response.data()[..response.data().len()]);
}

Ok(Response::new(sw.into(), out_data))
Expand Down

0 comments on commit 82b4bbb

Please sign in to comment.