[libfko] add NULL check to fko_get_raw_spa_digest_type() - bug discovered by fko-wrapper

This commit is contained in:
Michael Rash 2018-08-19 16:19:56 -07:00
parent d328278cb8
commit 4769d136d9
2 changed files with 5 additions and 1 deletions

View File

@ -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 * \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); 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, DLL_API int fko_afl_set_spa_data(fko_ctx_t ctx, const char * const enc_msg,
const int enc_msg_len); const int enc_msg_len);
#endif #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 * \return FKO_SUCCESS if successful, returns an error code otherwise
*/ */
DLL_API int fko_get_encoded_data(fko_ctx_t ctx, char **enc_data); DLL_API int fko_get_encoded_data(fko_ctx_t ctx, char **enc_data);
#if FUZZING_INTERFACES #if FUZZING_INTERFACES
DLL_API int fko_set_encoded_data(fko_ctx_t ctx, const char * const encoded_msg, 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); const int msg_len, const int do_digest, const int digest_type);

View File

@ -114,6 +114,9 @@ fko_get_raw_spa_digest_type(fko_ctx_t ctx, short *raw_digest_type)
if(!CTX_INITIALIZED(ctx)) if(!CTX_INITIALIZED(ctx))
return(FKO_ERROR_CTX_NOT_INITIALIZED); return(FKO_ERROR_CTX_NOT_INITIALIZED);
if(raw_digest_type == NULL)
return(FKO_ERROR_INVALID_DATA);
*raw_digest_type = ctx->raw_digest_type; *raw_digest_type = ctx->raw_digest_type;
return(FKO_SUCCESS); return(FKO_SUCCESS);