aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/ffi/ffi_hash.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-08-14 13:22:39 -0400
committerJack Lloyd <[email protected]>2018-08-14 13:22:39 -0400
commite97d29807011f465acd24e4a31c61b8ceca51d06 (patch)
treec3406ca549b305351937f38cfd0ced257abc7f84 /src/lib/ffi/ffi_hash.cpp
parent6c014c61237db5aa1d85ccd08416adaa55aed31e (diff)
Add some additional null pointer arg checks to FFI
Diffstat (limited to 'src/lib/ffi/ffi_hash.cpp')
-rw-r--r--src/lib/ffi/ffi_hash.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/ffi/ffi_hash.cpp b/src/lib/ffi/ffi_hash.cpp
index 601d97c52..b8ad4a85a 100644
--- a/src/lib/ffi/ffi_hash.cpp
+++ b/src/lib/ffi/ffi_hash.cpp
@@ -38,11 +38,15 @@ int botan_hash_destroy(botan_hash_t hash)
int botan_hash_output_length(botan_hash_t hash, size_t* out)
{
+ if(out == nullptr)
+ return BOTAN_FFI_ERROR_NULL_POINTER;
return BOTAN_FFI_DO(Botan::HashFunction, hash, h, { *out = h.output_length(); });
}
int botan_hash_block_size(botan_hash_t hash, size_t* out)
{
+ if(out == nullptr)
+ return BOTAN_FFI_ERROR_NULL_POINTER;
return BOTAN_FFI_DO(Botan::HashFunction, hash, h, { *out = h.hash_block_size(); });
}
@@ -53,11 +57,19 @@ int botan_hash_clear(botan_hash_t hash)
int botan_hash_update(botan_hash_t hash, const uint8_t* buf, size_t len)
{
+ if(len == 0)
+ return 0;
+
+ if(buf == nullptr)
+ return BOTAN_FFI_ERROR_NULL_POINTER;
+
return BOTAN_FFI_DO(Botan::HashFunction, hash, h, { h.update(buf, len); });
}
int botan_hash_final(botan_hash_t hash, uint8_t out[])
{
+ if(out == nullptr)
+ return BOTAN_FFI_ERROR_NULL_POINTER;
return BOTAN_FFI_DO(Botan::HashFunction, hash, h, { h.final(out); });
}
@@ -69,6 +81,9 @@ int botan_hash_copy_state(botan_hash_t* dest, const botan_hash_t source)
int botan_hash_name(botan_hash_t hash, char* name, size_t* name_len)
{
+ if(name_len == nullptr)
+ return BOTAN_FFI_ERROR_NULL_POINTER;
+
return BOTAN_FFI_DO(Botan::HashFunction, hash, h, {
return write_str_output(name, name_len, h.name()); });
}