From 26f2c8047472cffde13d0be280a001733cbf44c7 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Sat, 19 Nov 2022 13:50:56 +0100 Subject: [PATCH] Return error on the TODO cases Avoid crashing done by todo!() by returning error instead --- Cargo.toml | 2 +- src/tag.rs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4d81457..e33a4fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "flexiber" -version = "0.1.0" +version = "0.1.1" authors = ["Nicolas Stalder ", "RustCrypto Developers"] license = "Apache-2.0 OR MIT" edition = "2018" diff --git a/src/tag.rs b/src/tag.rs index afb883d..36d2fed 100644 --- a/src/tag.rs +++ b/src/tag.rs @@ -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)); } } }