From 4769d136d9a72ca90fa5e38213cb49d7f415313d Mon Sep 17 00:00:00 2001 From: Michael Rash Date: Sun, 19 Aug 2018 16:19:56 -0700 Subject: [PATCH] [libfko] add NULL check to fko_get_raw_spa_digest_type() - bug discovered by fko-wrapper --- lib/fko.h | 3 ++- lib/fko_digest.c | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/fko.h b/lib/fko.h index 6c7d01bd..32808258 100644 --- a/lib/fko.h +++ b/lib/fko.h @@ -649,8 +649,8 @@ DLL_API int fko_set_spa_encryption_mode(fko_ctx_t ctx, const int encrypt_mode); * \return FKO_SUCCESS if successful, returns an error code otherwise */ DLL_API int fko_set_spa_data(fko_ctx_t ctx, const char * const enc_msg); -#if AFL_FUZZING +#if AFL_FUZZING DLL_API int fko_afl_set_spa_data(fko_ctx_t ctx, const char * const enc_msg, const int enc_msg_len); #endif @@ -856,6 +856,7 @@ DLL_API int fko_get_spa_hmac(fko_ctx_t ctx, char **enc_data); * \return FKO_SUCCESS if successful, returns an error code otherwise */ DLL_API int fko_get_encoded_data(fko_ctx_t ctx, char **enc_data); + #if FUZZING_INTERFACES DLL_API int fko_set_encoded_data(fko_ctx_t ctx, const char * const encoded_msg, const int msg_len, const int do_digest, const int digest_type); diff --git a/lib/fko_digest.c b/lib/fko_digest.c index 7994a9d1..0c543e68 100644 --- a/lib/fko_digest.c +++ b/lib/fko_digest.c @@ -114,6 +114,9 @@ fko_get_raw_spa_digest_type(fko_ctx_t ctx, short *raw_digest_type) if(!CTX_INITIALIZED(ctx)) return(FKO_ERROR_CTX_NOT_INITIALIZED); + if(raw_digest_type == NULL) + return(FKO_ERROR_INVALID_DATA); + *raw_digest_type = ctx->raw_digest_type; return(FKO_SUCCESS);