mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
fix(vault): don't panic when reading backup::PayloadType off an empty
vec
This commit is contained in:
parent
9e0b63c871
commit
dca1ec86de
1 changed files with 5 additions and 1 deletions
|
|
@ -334,12 +334,16 @@ impl From<&PayloadType> for u8 {
|
|||
|
||||
#[derive(Debug)]
|
||||
pub enum PayloadTypeError {
|
||||
BadType
|
||||
BadType,
|
||||
}
|
||||
|
||||
impl TryFrom<&Vec<u8>> for PayloadType {
|
||||
type Error = PayloadTypeError;
|
||||
fn try_from(u: &Vec<u8>) -> Result<PayloadType, Self::Error> {
|
||||
if u.is_empty() {
|
||||
return Err(PayloadTypeError::BadType);
|
||||
}
|
||||
|
||||
match u[0] {
|
||||
1 => Ok(PayloadType::TOTP),
|
||||
2 => Ok(PayloadType::Password),
|
||||
|
|
|
|||
Loading…
Reference in a new issue