Fixed FFI allowing 0 sized dynamic salts.

Fortune for kana-hash's current commit: Future small blessing − 末小吉
master
Avril 3 years ago
parent 70abb4303a
commit 8aa126596d
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -20,6 +20,7 @@ opt-level = 3
lto = "fat" lto = "fat"
codegen-units = 1 codegen-units = 1
panic = "unwind" panic = "unwind"
strip=false
[dependencies] [dependencies]
sha2 = "0.9" sha2 = "0.9"

@ -144,7 +144,7 @@ const MAX_FFI_SALT_SIZE: usize = 1024;
{ {
let ffi = &*ptr; let ffi = &*ptr;
match ffi.salt_type { match ffi.salt_type {
SALT_TYPE_SPECIFIC => { SALT_TYPE_SPECIFIC if ffi.size > 0 => {
Salt::Dynamic(HeapArray::from_raw_copied(ffi.body as *const u8, usize::try_from(ffi.size).unwrap()).into_boxed_slice()) Salt::Dynamic(HeapArray::from_raw_copied(ffi.body as *const u8, usize::try_from(ffi.size).unwrap()).into_boxed_slice())
}, },
SALT_TYPE_DEFAULT => { SALT_TYPE_DEFAULT => {
@ -158,7 +158,7 @@ const MAX_FFI_SALT_SIZE: usize = 1024;
{ {
let ffi = &mut *ptr; let ffi = &mut *ptr;
let out = match ffi.salt_type { let out = match ffi.salt_type {
SALT_TYPE_SPECIFIC => { SALT_TYPE_SPECIFIC if ffi.size > 0 => {
Salt::Dynamic(HeapArray::from_raw_parts(ffi.body as *mut u8, usize::try_from(ffi.size).unwrap()).into_boxed_slice()) Salt::Dynamic(HeapArray::from_raw_parts(ffi.body as *mut u8, usize::try_from(ffi.size).unwrap()).into_boxed_slice())
}, },
SALT_TYPE_DEFAULT => { SALT_TYPE_DEFAULT => {

Loading…
Cancel
Save