From c70458f10aa9ffc3674374e3356da6b60b34b620 Mon Sep 17 00:00:00 2001 From: Susnata Date: Wed, 21 Mar 2018 09:10:01 -0400 Subject: [PATCH] [UTC][fido-client][Non-ACR][SVACE Modifications WGID 70270, 70271, 147423] SVACE Issues Fixed Change-Id: Iee25055e5fe3bd6531c4562dd542cada89e02076 Signed-off-by: Susnata --- src/common/assert.h | 20 ++++++++++++++++++ src/utc/fido-client/utc-fido-client.c | 39 +++++++++++++++++++++-------------- 2 files changed, 43 insertions(+), 16 deletions(-) diff --git a/src/common/assert.h b/src/common/assert.h index 56f7245..787ef62 100755 --- a/src/common/assert.h +++ b/src/common/assert.h @@ -38,6 +38,26 @@ } \ } while (0) +#define assert_eq_no_return(var, ref) \ + do { \ + if (var != ref) { \ + fprintf(stderr, \ + "\\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) and (%s == 0x%x) are not equal\\n", \ + __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \ + return ; \ + } \ + } while (0) + +#define assert_neq_no_return(var, ref) \ + do { \ + if (var == ref) { \ + fprintf(stderr, \ + "\\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) and (%s == 0x%x) are equal\\n", \ + __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \ + return ; \ + } \ + } while (0) + #define assert_neq(var, ref) \ do { \ if (var == ref) { \ diff --git a/src/utc/fido-client/utc-fido-client.c b/src/utc/fido-client/utc-fido-client.c index b67c694..feb29ed 100755 --- a/src/utc/fido-client/utc-fido-client.c +++ b/src/utc/fido-client/utc-fido-client.c @@ -186,19 +186,21 @@ void utc_fido_client_startup(void) ret = fido_uaf_is_supported(JSON_INVALID_STRING, &is_supported); if(!g_feature) { - assert_eq(ret, FIDO_ERROR_NOT_SUPPORTED); + assert_eq_no_return(ret, FIDO_ERROR_NOT_SUPPORTED); return ; } - assert_eq(ret, FIDO_ERROR_NONE); - assert_eq(is_supported, false); + assert_eq_no_return(ret, FIDO_ERROR_NONE); + assert_eq_no_return(is_supported, false); + + return ; } /** * @function utc_fido_client_cleanup * @description Called before each test * @parameter NA - * @return NA + * @return NA */ void utc_fido_client_cleanup(void) { @@ -742,60 +744,65 @@ __get_authinfo_string(const fido_authenticator_h auth) *res = 0; fido_authenticator_foreach_attestation_type(auth, fido_attestation_type_cb_list, res); - if(*res == 1) - return false; + if(*res == 1) { + goto error; + } fido_auth_algo_e get_algo = -1; fido_authenticator_get_algorithm(auth, &get_algo); if (get_algo == -1) { - return false; + goto error ; } fido_auth_user_verify_type_e user_ver = -1; fido_authenticator_get_verification_method(auth, &user_ver); if (user_ver == -1) { - return false; + goto error; } fido_auth_key_protection_type_e key_protection = -1; fido_authenticator_get_key_protection_method(auth, &key_protection); if (key_protection == -1) { - return false; + goto error ; } fido_auth_matcher_protection_type_e matcher_protection = -1; fido_authenticator_get_matcher_protection_method(auth, &matcher_protection); if (matcher_protection == -1) { - return false; + goto error ; } fido_auth_attachment_hint_e attachment_hint = -1; fido_authenticator_get_attachment_hint(auth, &attachment_hint); if (attachment_hint == -1) { - return false; + goto error ; } fido_auth_tc_display_type_e tc_discplay = -1; fido_authenticator_get_tc_discplay(auth, &tc_discplay); if (tc_discplay == -1) { - return false; + goto error ; } char *tc_display_type = NULL; fido_authenticator_get_tc_display_type(auth, &tc_display_type); if (!tc_display_type) { - return false; + goto error ; } free(tc_display_type); char *icon = NULL; fido_authenticator_get_icon(auth, &icon); if (!icon) { - return false; + goto error ; } free(icon); - + free(res); return true; + +error: + free(res); + return false; } static void @@ -819,8 +826,8 @@ int utc_fido_client_foreach_authenticator_p(void) int ret = fido_foreach_authenticator(auth_list_cb, res); if(!g_feature) { - assert_eq(ret, FIDO_ERROR_NOT_SUPPORTED); free(res); + assert_eq(ret, FIDO_ERROR_NOT_SUPPORTED); return 0; } -- 2.7.4