From 8aa126596d22d78f692c2fcc6c9595fb50c9eef1 Mon Sep 17 00:00:00 2001 From: Avril Date: Fri, 18 Mar 2022 20:29:00 +0000 Subject: [PATCH] Fixed FFI allowing 0 sized dynamic salts. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fortune for kana-hash's current commit: Future small blessing − 末小吉 --- Cargo.toml | 1 + src/salt.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index dd3517b..49e5bee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,7 @@ opt-level = 3 lto = "fat" codegen-units = 1 panic = "unwind" +strip=false [dependencies] sha2 = "0.9" diff --git a/src/salt.rs b/src/salt.rs index 7f38fee..6662c1c 100644 --- a/src/salt.rs +++ b/src/salt.rs @@ -144,7 +144,7 @@ const MAX_FFI_SALT_SIZE: usize = 1024; { let ffi = &*ptr; 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_TYPE_DEFAULT => { @@ -158,7 +158,7 @@ const MAX_FFI_SALT_SIZE: usize = 1024; { let ffi = &mut *ptr; 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_TYPE_DEFAULT => {