mirror of
https://github.com/chatmail/core.git
synced 2026-04-28 10:56:29 +03:00
fix(key): return None when empty binary is loaded (#96)
This commit is contained in:
committed by
Lars-Magnus Skog
parent
3ade0a1de8
commit
a674557f07
@@ -106,8 +106,9 @@ impl Key {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_binary(data: *const u8, len: libc::c_int, key_type: KeyType) -> Option<Self> {
|
pub fn from_binary(data: *const u8, len: libc::c_int, key_type: KeyType) -> Option<Self> {
|
||||||
assert!(!data.is_null(), "missing data");
|
if data.is_null() || len == 0 {
|
||||||
assert!(len > 0);
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
let bytes = unsafe { slice::from_raw_parts(data, len as usize) };
|
let bytes = unsafe { slice::from_raw_parts(data, len as usize) };
|
||||||
Self::from_slice(bytes, key_type)
|
Self::from_slice(bytes, key_type)
|
||||||
|
|||||||
Reference in New Issue
Block a user