[libfko] added fault injections for remaining ...set...() functions called by fko_new()
This commit is contained in:
parent
5f227cfa48
commit
597a3d3953
@ -40,11 +40,18 @@ static int
|
||||
set_spa_digest_type(fko_ctx_t ctx,
|
||||
short *digest_type_field, const short digest_type)
|
||||
{
|
||||
#if HAVE_LIBFIU
|
||||
fiu_return_on("set_spa_digest_type_init", FKO_ERROR_CTX_NOT_INITIALIZED);
|
||||
#endif
|
||||
/* Must be initialized
|
||||
*/
|
||||
if(!CTX_INITIALIZED(ctx))
|
||||
return(FKO_ERROR_CTX_NOT_INITIALIZED);
|
||||
|
||||
#if HAVE_LIBFIU
|
||||
fiu_return_on("set_spa_digest_type_val",
|
||||
FKO_ERROR_INVALID_DATA_ENCODE_DIGEST_VALIDFAIL);
|
||||
#endif
|
||||
if(digest_type < 1 || digest_type >= FKO_LAST_DIGEST_TYPE)
|
||||
return(FKO_ERROR_INVALID_DATA_ENCODE_DIGEST_VALIDFAIL);
|
||||
|
||||
|
||||
@ -478,11 +478,19 @@ gpg_decrypt(fko_ctx_t ctx, const char *dec_key)
|
||||
int
|
||||
fko_set_spa_encryption_type(fko_ctx_t ctx, const short encrypt_type)
|
||||
{
|
||||
#if HAVE_LIBFIU
|
||||
fiu_return_on("fko_set_spa_encryption_type_init",
|
||||
FKO_ERROR_CTX_NOT_INITIALIZED);
|
||||
#endif
|
||||
/* Must be initialized
|
||||
*/
|
||||
if(!CTX_INITIALIZED(ctx))
|
||||
return(FKO_ERROR_CTX_NOT_INITIALIZED);
|
||||
|
||||
#if HAVE_LIBFIU
|
||||
fiu_return_on("fko_set_spa_encryption_type_val",
|
||||
FKO_ERROR_INVALID_DATA_ENCRYPT_TYPE_VALIDFAIL);
|
||||
#endif
|
||||
if(encrypt_type < 0 || encrypt_type >= FKO_LAST_ENCRYPTION_TYPE)
|
||||
return(FKO_ERROR_INVALID_DATA_ENCRYPT_TYPE_VALIDFAIL);
|
||||
|
||||
@ -513,11 +521,19 @@ fko_get_spa_encryption_type(fko_ctx_t ctx, short *enc_type)
|
||||
int
|
||||
fko_set_spa_encryption_mode(fko_ctx_t ctx, const int encrypt_mode)
|
||||
{
|
||||
#if HAVE_LIBFIU
|
||||
fiu_return_on("fko_set_spa_encryption_mode_init",
|
||||
FKO_ERROR_CTX_NOT_INITIALIZED);
|
||||
#endif
|
||||
/* Must be initialized
|
||||
*/
|
||||
if(!CTX_INITIALIZED(ctx))
|
||||
return(FKO_ERROR_CTX_NOT_INITIALIZED);
|
||||
|
||||
#if HAVE_LIBFIU
|
||||
fiu_return_on("fko_set_spa_encryption_mode_val",
|
||||
FKO_ERROR_INVALID_DATA_ENCRYPT_MODE_VALIDFAIL);
|
||||
#endif
|
||||
if(encrypt_mode < 0 || encrypt_mode >= FKO_LAST_ENC_MODE)
|
||||
return(FKO_ERROR_INVALID_DATA_ENCRYPT_MODE_VALIDFAIL);
|
||||
|
||||
|
||||
@ -102,11 +102,19 @@ have_port(const char *msg)
|
||||
int
|
||||
fko_set_spa_message_type(fko_ctx_t ctx, const short msg_type)
|
||||
{
|
||||
#if HAVE_LIBFIU
|
||||
fiu_return_on("fko_set_spa_message_type_init",
|
||||
FKO_ERROR_CTX_NOT_INITIALIZED);
|
||||
#endif
|
||||
/* Must be initialized
|
||||
*/
|
||||
if(!CTX_INITIALIZED(ctx))
|
||||
return FKO_ERROR_CTX_NOT_INITIALIZED;
|
||||
|
||||
#if HAVE_LIBFIU
|
||||
fiu_return_on("fko_set_spa_message_type_val",
|
||||
FKO_ERROR_INVALID_DATA_MESSAGE_TYPE_VALIDFAIL);
|
||||
#endif
|
||||
if(msg_type < 0 || msg_type >= FKO_LAST_MSG_TYPE)
|
||||
return(FKO_ERROR_INVALID_DATA_MESSAGE_TYPE_VALIDFAIL);
|
||||
|
||||
|
||||
@ -39,6 +39,10 @@ fko_set_timestamp(fko_ctx_t ctx, const int offset)
|
||||
{
|
||||
time_t ts;
|
||||
|
||||
#if HAVE_LIBFIU
|
||||
fiu_return_on("fko_set_timestamp_init", FKO_ERROR_CTX_NOT_INITIALIZED);
|
||||
#endif
|
||||
|
||||
/* Must be initialized
|
||||
*/
|
||||
if(!CTX_INITIALIZED(ctx))
|
||||
@ -46,6 +50,10 @@ fko_set_timestamp(fko_ctx_t ctx, const int offset)
|
||||
|
||||
ts = time(NULL) + offset;
|
||||
|
||||
#if HAVE_LIBFIU
|
||||
fiu_return_on("fko_set_timestamp_val",
|
||||
FKO_ERROR_INVALID_DATA_TIMESTAMP_VALIDFAIL);
|
||||
#endif
|
||||
if(ts < 0)
|
||||
return(FKO_ERROR_INVALID_DATA_TIMESTAMP_VALIDFAIL);
|
||||
|
||||
|
||||
@ -16,7 +16,19 @@ const char *fiu_tags[] = {
|
||||
"fko_set_username_init",
|
||||
"fko_set_username_strdup1",
|
||||
"fko_set_username_valuser",
|
||||
"fko_set_username_strdup2"
|
||||
"fko_set_username_strdup2",
|
||||
"fko_set_timestamp_init",
|
||||
"fko_set_timestamp_val",
|
||||
"set_spa_digest_type_init",
|
||||
"set_spa_digest_type_val",
|
||||
"fko_set_spa_encryption_type_init",
|
||||
"fko_set_spa_encryption_type_val",
|
||||
"fko_set_spa_encryption_mode_init",
|
||||
"fko_set_spa_encryption_mode_val",
|
||||
"fko_set_spa_message_type_init",
|
||||
"fko_set_spa_message_type_val",
|
||||
"fko_set_timestamp_init",
|
||||
"fko_set_timestamp_val"
|
||||
};
|
||||
const int fiu_rvs[] = {
|
||||
FKO_ERROR_MEMORY_ALLOCATION,
|
||||
@ -30,7 +42,19 @@ const int fiu_rvs[] = {
|
||||
FKO_ERROR_CTX_NOT_INITIALIZED,
|
||||
FKO_ERROR_MEMORY_ALLOCATION,
|
||||
FKO_ERROR_INVALID_DATA,
|
||||
FKO_ERROR_MEMORY_ALLOCATION
|
||||
FKO_ERROR_MEMORY_ALLOCATION,
|
||||
FKO_ERROR_CTX_NOT_INITIALIZED,
|
||||
FKO_ERROR_INVALID_DATA_TIMESTAMP_VALIDFAIL,
|
||||
FKO_ERROR_CTX_NOT_INITIALIZED,
|
||||
FKO_ERROR_INVALID_DATA_ENCODE_DIGEST_VALIDFAIL,
|
||||
FKO_ERROR_CTX_NOT_INITIALIZED,
|
||||
FKO_ERROR_INVALID_DATA_ENCRYPT_TYPE_VALIDFAIL,
|
||||
FKO_ERROR_CTX_NOT_INITIALIZED,
|
||||
FKO_ERROR_INVALID_DATA_ENCRYPT_MODE_VALIDFAIL,
|
||||
FKO_ERROR_CTX_NOT_INITIALIZED,
|
||||
FKO_ERROR_INVALID_DATA_MESSAGE_TYPE_VALIDFAIL,
|
||||
FKO_ERROR_CTX_NOT_INITIALIZED,
|
||||
FKO_ERROR_INVALID_DATA_TIMESTAMP_VALIDFAIL
|
||||
};
|
||||
|
||||
int main(void) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user