Return error on the TODO cases

Avoid crashing done by todo!() by returning error instead
This commit is contained in:
Szczepan Zalega
2022-11-19 13:51:06 +01:00
parent 825eba57df
commit 26f2c80474
2 changed files with 5 additions and 3 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "flexiber"
version = "0.1.0"
version = "0.1.1"
authors = ["Nicolas Stalder <n@stalder.io>", "RustCrypto Developers"]
license = "Apache-2.0 OR MIT"
edition = "2018"
+4 -2
View File
@@ -174,7 +174,8 @@ impl Encodable for Tag {
encoder.byte((self.number & 0x7F) as u8)
}
0x4000..=0xFFFF => {
todo!();
// todo()
return Err(Error::from(ErrorKind::UnsupportedTagSize));
}
}
}
@@ -203,7 +204,8 @@ impl Decodable<'_> for Tag {
if third_byte & NOT_LAST_TAG_OCTET_FLAG == 0 {
((number as u16) << 7) | (third_byte as u16)
} else {
todo!();
// todo()
return Err(Error::from(ErrorKind::InvalidLength));
}
}
}