crypto_data_hkdf/4: do not crash for length > usize::max_value()

For now, we fail silently in such cases.

Noted by @notoria in #533. Many thanks!
This commit is contained in:
Markus Triska
2020-05-19 17:31:36 +02:00
parent 34f7752c0f
commit d19d8ea770

View File

@@ -5285,11 +5285,12 @@ impl MachineState {
usize::try_from(n).unwrap()
}
Ok(Number::Integer(n)) => {
n.to_usize().unwrap()
}
_ => {
unreachable!()
match n.to_usize() {
Some(u) => { u }
_ => { self.fail = true; return Ok(()); }
}
}
_ => { unreachable!() }
};
let ints_list =