Skip to content

Commit 19aa61b

Browse files
authored
der: track reader error position in ObjectIdentifier::decode_value (#2080)
1 parent 5755d9b commit 19aa61b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

der/src/asn1/oid.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ impl<'a, const MAX_SIZE: usize> DecodeValue<'a> for ObjectIdentifier<MAX_SIZE> {
1616
let mut buf = [0u8; MAX_SIZE];
1717
let slice = buf
1818
.get_mut(..header.length().try_into()?)
19-
.ok_or_else(|| Self::TAG.length_error())?;
19+
.ok_or_else(|| reader.error(Self::TAG.length_error()))?;
2020

2121
let actual_len = reader.read_into(slice)?.len();
2222
debug_assert_eq!(actual_len, header.length().try_into()?);
23-
Ok(ObjectIdentifierRef::from_bytes(slice)?.try_into()?)
23+
24+
ObjectIdentifierRef::from_bytes(slice)
25+
.and_then(TryInto::try_into)
26+
.map_err(|oid_err| reader.error(Error::from(oid_err).kind()))
2427
}
2528
}
2629

0 commit comments

Comments
 (0)