Skip to content

Commit d516392

Browse files
Handle overlong icon values
We skip the icon field during deserialization if it is too long. Previously, we directly tried to deserialize a String<N> and ignored any errors. This means that we also ignored any other errors, e. g. for invalid data types. This patch changes the implementation to first deserialize a string slice and handle errors occuring during the deserialization. Then we check if the string slice fits into String<N> or if we should ignore the value.
1 parent 084db87 commit d516392

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
- Remove `AuthenticatorDataFlags::EMPTY` (use `AuthenticatorDataFlags::empty()` instead)
1717
- Allow missing algorithms in COSE keys ([#8][])
1818
- Remove unused `REALISTIC_MAX_MESSAGE_SIZE` constant
19+
- Handle overlong `icon` values in `PublicKeyCredentialUserEntity` ([#27][])
1920

2021
[#8]: https://github.com/trussed-dev/ctap-types/pull/8
2122
[#9]: https://github.com/solokeys/ctap-types/issues/9
@@ -24,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2425
[#16]: https://github.com/trussed-dev/ctap-types/pull/16
2526
[#17]: https://github.com/trussed-dev/ctap-types/pull/17
2627
[#18]: https://github.com/trussed-dev/ctap-types/pull/18
28+
[#27]: https://github.com/trussed-dev/ctap-types/pull/27
2729

2830
## [0.1.2] - 2022-03-07
2931

src/webauthn.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ fn deserialize_from_str_and_skip_if_too_long<'de, D, const L: usize>(
7171
where
7272
D: serde::Deserializer<'de>,
7373
{
74-
let result: Result<String<L>, D::Error> = serde::Deserialize::deserialize(deserializer);
75-
match result {
74+
let s: &'de str = Deserialize::deserialize(deserializer)?;
75+
// String::from(s) could panic and is not really infallibe. It is removed in heapless 0.8.
76+
#[allow(clippy::unnecessary_fallible_conversions)]
77+
match String::try_from(s) {
7678
Ok(string) => Ok(Some(string)),
7779
Err(_err) => {
7880
info_now!("skipping field: {:?}", _err);

0 commit comments

Comments
 (0)