mirror of
https://github.com/trussed-dev/iso7816.git
synced 2026-06-20 04:16:14 -07:00
Rename CanThisReallyOccur to InvalidSliceLength
The CanThisReallyOccur error variant can really occur, namely if the slice length is invalid, i. e. either the encoded data length Lc is wrong, or the length values Lc and Le are not encoded properly. Therefore, this patch renames the CanThisReallyOccur variant to a more informative name.
This commit is contained in:
committed by
Nicolas Stalder
parent
d09d3cdaeb
commit
e2dae292be
+6
-2
@@ -74,7 +74,7 @@ pub enum FromSliceError {
|
||||
TooShort,
|
||||
InvalidClass,
|
||||
InvalidFirstBodyByteForExtended,
|
||||
CanThisReallyOccur,
|
||||
InvalidSliceLength,
|
||||
}
|
||||
|
||||
impl From<class::InvalidClass> for FromSliceError {
|
||||
@@ -216,7 +216,11 @@ fn parse_lengths(body: &[u8]) -> Result<ParsedLengths, FromSliceError> {
|
||||
return Ok(parsed);
|
||||
}
|
||||
|
||||
Err(FromSliceError::CanThisReallyOccur)
|
||||
// If we haven’t returned yet, the slice has an invalid length: Either the encoded lc value is
|
||||
// wrong, or the lc and le lengths are not encoded properly (one byte per value for simple
|
||||
// APDU, two bytes per value for extended APDU).
|
||||
|
||||
Err(FromSliceError::InvalidSliceLength)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user