Re-instate the length check for Le bytes

This commit is contained in:
Kamran Khan
2020-12-14 04:54:25 -08:00
parent dbbdddd58b
commit 35bdfe90ed
2 changed files with 4 additions and 1 deletions

View File

@@ -179,6 +179,9 @@ impl TryFrom<&[u8]> for APDU {
.len() .len()
.checked_sub(extended_apdu_lc + 3) .checked_sub(extended_apdu_lc + 3)
.ok_or(ApduStatusCode::SW_WRONG_LENGTH)?; .ok_or(ApduStatusCode::SW_WRONG_LENGTH)?;
if extended_apdu_le_len > 3 {
return Err(ApduStatusCode::SW_WRONG_LENGTH);
}
if byte_0 == 0 && extended_apdu_le_len <= 3 { if byte_0 == 0 && extended_apdu_le_len <= 3 {
// If first byte is zero AND the next two bytes can be parsed as a big-endian // If first byte is zero AND the next two bytes can be parsed as a big-endian

View File

@@ -542,7 +542,7 @@ mod test {
message.push(0x00); message.push(0x00);
let response = Ctap1Command::process_command(&message, &mut ctap_state, START_CLOCK_VALUE); let response = Ctap1Command::process_command(&message, &mut ctap_state, START_CLOCK_VALUE);
assert_eq!(response, Err(Ctap1StatusCode::SW_INTERNAL_EXCEPTION)); assert_eq!(response, Err(Ctap1StatusCode::SW_WRONG_LENGTH));
} }
#[test] #[test]