Skip to content

Commit

Permalink
Add null check
Browse files Browse the repository at this point in the history
  • Loading branch information
neithanmo committed Apr 8, 2024
1 parent dd742ca commit f533b81
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ pub unsafe extern "C" fn verify_bls_sign(
key: *const u8,
sig: *const u8,
) -> u8 {
// Check for null pointers before converting to slices
if msg.is_null() || key.is_null() || sig.is_null() {
return 0;
}

let msg = std::slice::from_raw_parts(msg, msg_len as usize);
let key = std::slice::from_raw_parts(key, BLS_PUBLIC_KEY_SIZE);
let sig = std::slice::from_raw_parts(sig, BLS_SIGNATURE_SIZE);
Expand Down

0 comments on commit f533b81

Please sign in to comment.