From 3b6bf02f1f4d9b269c5de3635b723cf9d6059101 Mon Sep 17 00:00:00 2001 From: Manasij Sur Roy Date: Tue, 26 Apr 2016 14:39:59 +0530 Subject: [PATCH] Coding idiom fixes Change-Id: Ie351a94d3c23515dd7802cb7120934469ae6cc96 Signed-off-by: Manasij Sur Roy --- common/fido_b64_util.c | 12 ++-- common/fido_json_handler.c | 119 ++++++++++++++++++------------------- common/fido_tlv_util.c | 80 ++++++++++++------------- common/fido_uaf_utils.c | 4 +- fido_svc_ui/fido_ui_server.c | 10 ++-- server/fido_app_id_handler.c | 18 +++--- server/fido_asm_plugin_manager.c | 2 +- server/fido_privilege_checker.c | 24 ++++---- server/fido_selection_ui_adaptor.c | 6 +- server/fido_server.c | 2 +- server/fido_uaf_policy_checker.c | 75 ++++++++++++----------- test/FIDOSample/src/main.c | 48 +++++++-------- test/Fido_Sample_RPM/src/main.c | 8 +-- test/shell_tc/fido_shell_tc.c | 2 +- test/shell_tc/fido_shell_tc_util.c | 2 +- 15 files changed, 204 insertions(+), 208 deletions(-) diff --git a/common/fido_b64_util.c b/common/fido_b64_util.c index 22baaa1..0599c29 100644 --- a/common/fido_b64_util.c +++ b/common/fido_b64_util.c @@ -32,7 +32,7 @@ _fido_b64url_encode(const unsigned char *input, int inlen, unsigned char *outpu BIO * b64 = NULL; BUF_MEM * bptr = NULL; b64 = BIO_new(BIO_f_base64()); - if(b64 == NULL) { + if (b64 == NULL) { _ERR("BIO_new with BIO_f_base64 failed "); return -1; } @@ -50,14 +50,14 @@ _fido_b64url_encode(const unsigned char *input, int inlen, unsigned char *outpu *outlen = bptr->length; int i; - for(i =0; i < *outlen ; i++) { - if(output[i] == '+') + for (i =0; i < *outlen ; i++) { + if (output[i] == '+') output[i] = '-'; - else if(output[i] == '/') + else if (output[i] == '/') output[i] = '_'; - else if(output[i] == '=') { + else if (output[i] == '=') { *outlen = i ; output[i] = '\0'; break; @@ -79,7 +79,7 @@ _fido_b64url_decode(const unsigned char *in, int inlen, unsigned char *out, int int npadChars = (inlen %4) == 0 ? 0 : (4 - (inlen%4)); unsigned char *base64 = (unsigned char *) malloc(inlen + npadChars); - if(base64 == NULL) { + if (base64 == NULL) { _ERR("malloc failed"); return -1; } diff --git a/common/fido_json_handler.c b/common/fido_json_handler.c index eed18f8..e1d9d7a 100644 --- a/common/fido_json_handler.c +++ b/common/fido_json_handler.c @@ -21,7 +21,7 @@ #include #include #include -#if !GLIB_CHECK_VERSION (2, 31, 0) +#if !GLIB_CHECK_VERSION(2, 31, 0) #include #endif #include @@ -160,7 +160,7 @@ __uaf_composer_compose_asm_init(JsonGenerator **generator, JsonObject **root_obj JsonNode *root_node = NULL; *generator = json_generator_new(); - if(*generator == NULL) { + if (*generator == NULL) { _INFO("json_generator_new is NULL"); goto CATCH; } @@ -172,7 +172,7 @@ __uaf_composer_compose_asm_init(JsonGenerator **generator, JsonObject **root_obj } *root_obj = json_object_new(); - if(*root_obj == NULL) { + if (*root_obj == NULL) { _INFO("json_object_new in NULL"); goto CATCH; } @@ -211,7 +211,7 @@ __uaf_composer_compose_asm_response_init(JsonGenerator **generator, JsonObject * JsonArray *rootArray = json_array_new(); *generator = json_generator_new(); - if(*generator == NULL) { + if (*generator == NULL) { _INFO("json_generator_new is NULL"); goto CATCH; } @@ -229,13 +229,13 @@ __uaf_composer_compose_asm_response_init(JsonGenerator **generator, JsonObject * } gen_object = json_object_new(); - if(gen_object == NULL) { + if (gen_object == NULL) { _INFO("json_object_new in NULL"); goto CATCH; } *root_obj = json_object_new(); - if(*root_obj == NULL) { + if (*root_obj == NULL) { _INFO("json_object_new in NULL"); goto CATCH; } @@ -287,7 +287,7 @@ __uaf_composer_compose_asm_version(_version_t *version, JsonNode **node) } JsonObject *obj = json_object_new(); - if(obj == NULL) { + if (obj == NULL) { _INFO("json_object_new in NULL"); goto CATCH; } @@ -300,7 +300,7 @@ __uaf_composer_compose_asm_version(_version_t *version, JsonNode **node) return TRUE; CATCH: - if (node !=NULL && *node != NULL) { + if ((node !=NULL) && (*node != NULL)) { json_node_free(*node); *node = NULL; } @@ -328,7 +328,7 @@ __uaf_composer_compose_asm_reg_in(_fido_asm_reg_in_t *reg_in, JsonNode **node) } JsonObject *obj = json_object_new(); - if(obj == NULL) { + if (obj == NULL) { _INFO("json_object_new in NULL"); goto CATCH; } @@ -379,7 +379,7 @@ __uaf_composer_compose_asm_auth_in(_fido_asm_auth_in_t *auth_in, JsonNode **node } JsonObject *obj = json_object_new(); - if(obj == NULL) { + if (obj == NULL) { _INFO("json_object_new in NULL"); goto CATCH; } @@ -400,10 +400,10 @@ __uaf_composer_compose_asm_auth_in(_fido_asm_auth_in_t *auth_in, JsonNode **node if (auth_in->final_challenge) json_object_set_string_member(obj, _JSON_KEY_FINAL_CHALLENGE, auth_in->final_challenge); - if(auth_in->trans_list != NULL) { + if (auth_in->trans_list != NULL) { JsonArray *transArray = json_array_new(); GList *iter = g_list_first(auth_in->trans_list); - while(iter != NULL) { + while (iter != NULL) { _fido_asm_transaction_t *val = (_fido_asm_transaction_t*)(iter->data); JsonNode *transNode = json_node_new(JSON_NODE_OBJECT); JsonObject *transObject = json_object_new(); @@ -414,7 +414,7 @@ __uaf_composer_compose_asm_auth_in(_fido_asm_auth_in_t *auth_in, JsonNode **node JsonNode *tcNode = json_node_new(JSON_NODE_OBJECT); JsonObject *tcObject = json_object_new(); - if(val->display_charac != NULL) { + if (val->display_charac != NULL) { json_object_set_int_member(tcObject, _JSON_KEY_WIDTH, val->display_charac->width); json_object_set_int_member(tcObject, _JSON_KEY_HEIGHT, val->display_charac->height); json_object_set_int_member(tcObject, _JSON_KEY_BIT_DEPTH, val->display_charac->bit_depth); @@ -423,11 +423,11 @@ __uaf_composer_compose_asm_auth_in(_fido_asm_auth_in_t *auth_in, JsonNode **node json_object_set_int_member(tcObject, _JSON_KEY_FILTER, val->display_charac->filter); json_object_set_int_member(tcObject, _JSON_KEY_INTERLACE, val->display_charac->interlace); - if(val->display_charac != NULL) { + if (val->display_charac != NULL) { JsonArray *plteArray = json_array_new(); GList *plte_iter = g_list_first(val->display_charac->plte); - while(plte_iter != NULL) { + while (plte_iter != NULL) { _fido_asm_rgb_pallette_entry_t *plte = (_fido_asm_rgb_pallette_entry_t*)(plte_iter->data); JsonNode *plteNode = json_node_new(JSON_NODE_OBJECT); JsonObject *plteObject = json_object_new(); @@ -1483,18 +1483,18 @@ _uaf_composer_compose_asm_reg_request(_version_t *version, int auth_index, _fido if (__uaf_composer_compose_asm_version(version, &version_node) != TRUE) { _INFO("__uaf_composer_compose_asm_version fail"); goto CATCH; - } - else + } else { json_object_set_member(root_obj, _JSON_KEY_ASM_VERSION, version_node); + } json_object_set_int_member(root_obj, _JSON_KEY_AUTH_INDEX, auth_index); if (!__uaf_composer_compose_asm_reg_in(reg_in, ®ister_node)) { _INFO("__uaf_composer_compose_asm_reg_in fail"); goto CATCH; - } - else + } else { json_object_set_member(root_obj, _JSON_KEY_ARGS, register_node); + } *asm_reg_json = json_generator_to_data(generator, NULL); @@ -1705,17 +1705,17 @@ _uaf_composer_compose_asm_auth_request(_version_t *version, int auth_index, _fid if (__uaf_composer_compose_asm_version(version, &version_node) != TRUE) { _INFO("_uaf_composer_compose_asm_auth_request fail"); goto CATCH; - } - else + } else { json_object_set_member(root_obj, _JSON_KEY_ASM_VERSION, version_node); + } /*args*/ if (__uaf_composer_compose_asm_auth_in(auth_in, &auth_node) != TRUE) { _INFO("_uaf_composer_compose_asm_auth_request fail"); goto CATCH; - } - else + } else { json_object_set_member(root_obj, _JSON_KEY_ARGS, auth_node); + } /*Transaction list composing*/ @@ -1843,9 +1843,9 @@ _uaf_composer_compose_asm_dereg_request(_version_t *version, int auth_index, _ma if (__uaf_composer_compose_asm_version(version, &version_node) != TRUE) { _INFO("_uaf_composer_compose_asm_dereg_request fail"); goto CATCH; - } - else + } else { json_object_set_member(root_obj, _JSON_KEY_ASM_VERSION, version_node); + } /*args*/ JsonNode *argNode = json_node_new(JSON_NODE_OBJECT); @@ -1995,7 +1995,7 @@ _uaf_composer_compose_final_challenge(const char *app_id, const char *challenge, JsonGenerator *generator = json_generator_new(); JsonObject *root_obj = json_object_new(); - if(__uaf_composer_compose_asm_init(&generator, &root_obj) != TRUE) { + if (__uaf_composer_compose_asm_init(&generator, &root_obj) != TRUE) { _INFO("_uaf_composer_compose_asm_init fail"); goto CATCH; } @@ -2007,7 +2007,7 @@ _uaf_composer_compose_final_challenge(const char *app_id, const char *challenge, JsonNode *jsonNode = NULL; JsonObject *jsonObject = json_object_new(); - if(ch_bin != NULL) { + if (ch_bin != NULL) { JsonParser *chb_parser = json_parser_new(); GError *chb_err = NULL; @@ -2017,17 +2017,17 @@ _uaf_composer_compose_final_challenge(const char *app_id, const char *challenge, } JsonNode *chb_root = json_parser_get_root(chb_parser); - if(chb_root == NULL) { + if (chb_root == NULL) { return NULL; } JsonObject *chb_root_obj = json_node_get_object(chb_root); - if(chb_root_obj == NULL) { + if (chb_root_obj == NULL) { return NULL; } char *end_pt = (char*)json_object_get_string_member(chb_root_obj, _JSON_KEY_SERVER_END_POINT); - char *cert =(char*)json_object_get_string_member(chb_root_obj, _JSON_KEY_TLS_SERVER_CERT); + char *cert = (char*)json_object_get_string_member(chb_root_obj, _JSON_KEY_TLS_SERVER_CERT); char *uni = (char*)json_object_get_string_member(chb_root_obj, _JSON_KEY_TLS_UNIQUE); char *cid = (char*)json_object_get_string_member(chb_root_obj, _JSON_KEY_CID_PUB_KEY); @@ -2075,12 +2075,12 @@ _uaf_composer_compose_final_challenge(const char *app_id, const char *challenge, return ((char*)fc_enc); CATCH: - if(generator!=NULL) { + if (generator != NULL) { g_object_unref(generator); generator = NULL; } - if(root_obj!=NULL) { + if (root_obj != NULL) { g_object_unref(root_obj); root_obj = NULL; } @@ -2255,7 +2255,7 @@ _uaf_composer_compose_uaf_process_response_reg(_op_header_t *header, char *final JsonGenerator *generator = json_generator_new(); JsonObject *root_obj = json_object_new(); - if(__uaf_composer_compose_asm_response_init(&generator, &root_obj) != TRUE) { + if (__uaf_composer_compose_asm_response_init(&generator, &root_obj) != TRUE) { _INFO("_uaf_composer_compose_asm_init fail"); goto CATCH; } @@ -2263,7 +2263,7 @@ _uaf_composer_compose_uaf_process_response_reg(_op_header_t *header, char *final /*header*/ JsonNode *_header = json_node_new(JSON_NODE_OBJECT); JsonObject *obj1 = json_object_new(); - if(obj1 == NULL) { + if (obj1 == NULL) { _INFO("json_object_new is NULL"); goto CATCH; } @@ -2274,7 +2274,7 @@ _uaf_composer_compose_uaf_process_response_reg(_op_header_t *header, char *final JsonNode *upv = json_node_new(JSON_NODE_OBJECT); JsonObject *obj2 = json_object_new(); - if(obj2 == NULL) { + if (obj2 == NULL) { _INFO("json_object_new is NULL"); goto CATCH; } @@ -2374,19 +2374,19 @@ _uaf_composer_compose_uaf_process_response_reg(_op_header_t *header, char *final _INFO("_uaf_composer_compose_uaf_process_response_reg return fail"); - if(generator!=NULL) { + if (generator != NULL) { g_object_unref(generator); generator = NULL; } return 0; CATCH: - if(generator!=NULL) { + if (generator != NULL) { g_object_unref(generator); generator = NULL; } - if(root_obj!=NULL) { + if (root_obj != NULL) { g_object_unref(root_obj); root_obj = NULL; } @@ -2436,7 +2436,7 @@ _uaf_composer_compose_dereg_request(_response_t *uaf_res) json_builder_add_int_value(upv_root, uaf_res->header->version->major); json_builder_set_member_name(upv_root, _JSON_KEY_MINOR); - json_builder_add_int_value(upv_root,uaf_res->header->version->minor); + json_builder_add_int_value(upv_root, uaf_res->header->version->minor); json_builder_end_object(upv_root); @@ -2554,7 +2554,7 @@ _uaf_composer_compose_dereg_request(_response_t *uaf_res) JsonGenerator *generator = json_generator_new(); JsonObject *root_obj = json_object_new(); - if(__uaf_composer_compose_asm_init(&generator, &root_obj) != TRUE) { + if (__uaf_composer_compose_asm_init(&generator, &root_obj) != TRUE) { _INFO("_uaf_composer_compose_asm_init fail"); goto CATCH; } @@ -2646,7 +2646,7 @@ _uaf_composer_compose_dereg_request(_response_t *uaf_res) gsize len = 0; char *dereg_json = json_generator_to_data(generator, &len); - if(generator!=NULL) { + if (generator != NULL) { g_object_unref(generator); generator = NULL; } @@ -2660,12 +2660,12 @@ _uaf_composer_compose_dereg_request(_response_t *uaf_res) return NULL; CATCH: - if(generator!=NULL) { + if (generator != NULL) { g_object_unref(generator); generator = NULL; } - if(root_obj!=NULL) { + if (root_obj != NULL) { g_object_unref(root_obj); root_obj = NULL; } @@ -2686,7 +2686,7 @@ __get_policy(JsonObject *uaf_object) RET_IF_FAIL(accepted_array != NULL, NULL); int accepted_len = json_array_get_length(accepted_array); - _INFO("Parser accepted list count [%d]", accepted_len); + _INFO("Parser accepted list count [%d]", accepted_len); _policy_t *policy_info = (_policy_t *)calloc(1, sizeof(_policy_t)); policy_info->is_keyid_present = false; @@ -2791,7 +2791,7 @@ __get_transaction_list(JsonObject *uaf_obj) int tr_arr_len = json_array_get_length(tr_arr); int i = 0; - for (; i< tr_arr_len; i++) { + for (; i < tr_arr_len; i++) { JsonObject *tr_obj = json_array_get_object_element(tr_arr, i); if (tr_obj != NULL) { @@ -2925,7 +2925,7 @@ _uaf_parser_parse_message(const char *uaf_json, const gchar *channel_binding) if (uaf_message_temp->header == NULL) continue; - if (strcmp(uaf_message_temp->header->operation, _UAF_OPERATION_NAME_KEY_REG) == 0){ + if (strcmp(uaf_message_temp->header->operation, _UAF_OPERATION_NAME_KEY_REG) == 0) { uaf_message_temp->data = (void *)__parse_uaf_reg_message(uaf_object); if (uaf_message_temp->data == NULL) { @@ -2933,8 +2933,7 @@ _uaf_parser_parse_message(const char *uaf_json, const gchar *channel_binding) g_object_unref(parser); return NULL; - } - else { + } else { uaf_message_temp->type = _MESSAGE_TYPE_REG; g_object_unref(parser); @@ -2943,7 +2942,7 @@ _uaf_parser_parse_message(const char *uaf_json, const gchar *channel_binding) } } - if (strcmp(uaf_message_temp->header->operation, _UAF_OPERATION_NAME_KEY_AUTH) == 0){ + if (strcmp(uaf_message_temp->header->operation, _UAF_OPERATION_NAME_KEY_AUTH) == 0) { uaf_message_temp->data = (void *)__parse_uaf_auth_message(uaf_object); if (uaf_message_temp->data == NULL) { @@ -2951,17 +2950,16 @@ _uaf_parser_parse_message(const char *uaf_json, const gchar *channel_binding) g_object_unref(parser); return NULL; - } - else { - uaf_message_temp->type = _MESSAGE_TYPE_AUTH; + } else { + uaf_message_temp->type = _MESSAGE_TYPE_AUTH; - g_object_unref(parser); - return uaf_message_temp; + g_object_unref(parser); + return uaf_message_temp; } } - if (strcmp(uaf_message_temp->header->operation, _UAF_OPERATION_NAME_KEY_DE_REG) == 0){ + if (strcmp(uaf_message_temp->header->operation, _UAF_OPERATION_NAME_KEY_DE_REG) == 0) { uaf_message_temp->data = (void *)__parse_uaf_dereg_message(uaf_object); if (uaf_message_temp->data == NULL) { @@ -2969,8 +2967,7 @@ _uaf_parser_parse_message(const char *uaf_json, const gchar *channel_binding) g_object_unref(parser); return NULL; - } - else { + } else { uaf_message_temp->type = _MESSAGE_TYPE_DEREG; g_object_unref(parser); @@ -3290,7 +3287,7 @@ _uaf_composer_compose_get_registrations_request(const char *auth_index) JsonGenerator *generator = json_generator_new(); JsonObject *root_obj = json_object_new(); - if(__uaf_composer_compose_asm_init(&generator, &root_obj) != TRUE) { + if (__uaf_composer_compose_asm_init(&generator, &root_obj) != TRUE) { _INFO("_uaf_composer_compse_asm_init fail"); goto CATCH; } @@ -3315,7 +3312,7 @@ _uaf_composer_compose_get_registrations_request(const char *auth_index) gsize len = 0; char *get_reg_json = json_generator_to_data(generator, &len); - if(generator != NULL) { + if (generator != NULL) { g_object_unref(generator); generator = NULL; } @@ -3323,12 +3320,12 @@ _uaf_composer_compose_get_registrations_request(const char *auth_index) return get_reg_json; CATCH: - if(generator != NULL) { + if (generator != NULL) { g_object_unref(generator); generator = NULL; } - if(root_obj != NULL) { + if (root_obj != NULL) { g_object_unref(root_obj); root_obj = NULL; } diff --git a/common/fido_tlv_util.c b/common/fido_tlv_util.c index 5060fe9..6b39c4d 100644 --- a/common/fido_tlv_util.c +++ b/common/fido_tlv_util.c @@ -76,71 +76,71 @@ __get_tlv_pack_by_type(const guchar *tlv_buffer_in, uint16_t type_in, int max_le _auth_reg_assertion_tlv_t* _tlv_util_decode_reg_assertion(char *tlv_enc) { - _INFO("_tlv_util_decode_reg_assertion"); + _INFO("_tlv_util_decode_reg_assertion"); - RET_IF_FAIL(tlv_enc != NULL, NULL); + RET_IF_FAIL(tlv_enc != NULL, NULL); - _INFO("%s", tlv_enc); + _INFO("%s", tlv_enc); - int in_len = strlen(tlv_enc); - int tlv_dec_len = in_len * 1.5; - unsigned char *tlv_dec = calloc(1, tlv_dec_len); + int in_len = strlen(tlv_enc); + int tlv_dec_len = in_len * 1.5; + unsigned char *tlv_dec = calloc(1, tlv_dec_len); - int r = _fido_b64url_decode((unsigned char *)tlv_enc, in_len, tlv_dec, &tlv_dec_len); + int r = _fido_b64url_decode((unsigned char *)tlv_enc, in_len, tlv_dec, &tlv_dec_len); RET_IF_FAIL(r == 0, NULL); - _INFO("in len = [%d], decoded len = [%d]", in_len, tlv_dec_len); + _INFO("in len = [%d], decoded len = [%d]", in_len, tlv_dec_len); - _tlv_t *reg_tlv = __get_tlv_pack_by_type(tlv_dec, TAG_UAFV1_REG_ASSERTION, tlv_dec_len); - if (reg_tlv != NULL) { - _INFO("Found TAG_UAFV1_REG_ASSERTION"); + _tlv_t *reg_tlv = __get_tlv_pack_by_type(tlv_dec, TAG_UAFV1_REG_ASSERTION, tlv_dec_len); + if (reg_tlv != NULL) { + _INFO("Found TAG_UAFV1_REG_ASSERTION"); - _free_tlv(reg_tlv); + _free_tlv(reg_tlv); - int krd_start_idx = 2 + 2; + int krd_start_idx = 2 + 2; - _tlv_t *krd_tlv = __get_tlv_pack_by_type(tlv_dec + krd_start_idx, TAG_UAFV1_KRD, (tlv_dec_len - krd_start_idx)); - if (krd_tlv != NULL) { - _INFO("Found TAG_UAFV1_KRD"); - _free_tlv(krd_tlv); + _tlv_t *krd_tlv = __get_tlv_pack_by_type(tlv_dec + krd_start_idx, TAG_UAFV1_KRD, (tlv_dec_len - krd_start_idx)); + if (krd_tlv != NULL) { + _INFO("Found TAG_UAFV1_KRD"); + _free_tlv(krd_tlv); - int krd_inner_start_idx = krd_start_idx + 2 + 2; + int krd_inner_start_idx = krd_start_idx + 2 + 2; - _tlv_t *aaid_tlv = __get_tlv_pack_by_type(tlv_dec + krd_inner_start_idx, TAG_AAID, (tlv_dec_len - krd_inner_start_idx)); + _tlv_t *aaid_tlv = __get_tlv_pack_by_type(tlv_dec + krd_inner_start_idx, TAG_AAID, (tlv_dec_len - krd_inner_start_idx)); - _tlv_t *key_id_tlv = __get_tlv_pack_by_type(tlv_dec + krd_inner_start_idx, TAG_KEYID, (tlv_dec_len - krd_inner_start_idx)); + _tlv_t *key_id_tlv = __get_tlv_pack_by_type(tlv_dec + krd_inner_start_idx, TAG_KEYID, (tlv_dec_len - krd_inner_start_idx)); - _auth_reg_assertion_tlv_t *assrt_tlv = (_auth_reg_assertion_tlv_t*)calloc(1, sizeof(_auth_reg_assertion_tlv_t)); + _auth_reg_assertion_tlv_t *assrt_tlv = (_auth_reg_assertion_tlv_t*)calloc(1, sizeof(_auth_reg_assertion_tlv_t)); - if (aaid_tlv != NULL) { - _INFO("Found TAG_AAID"); + if (aaid_tlv != NULL) { + _INFO("Found TAG_AAID"); - assrt_tlv->aaid = (char*)calloc(1, aaid_tlv->len + 1); - memcpy(assrt_tlv->aaid, aaid_tlv->val, aaid_tlv->len); + assrt_tlv->aaid = (char*)calloc(1, aaid_tlv->len + 1); + memcpy(assrt_tlv->aaid, aaid_tlv->val, aaid_tlv->len); - _free_tlv(aaid_tlv); - } + _free_tlv(aaid_tlv); + } - if (key_id_tlv != NULL) { - _INFO("Found TAG_KEYID"); + if (key_id_tlv != NULL) { + _INFO("Found TAG_KEYID"); - assrt_tlv->key_id = (unsigned char*)calloc(1, key_id_tlv->len); - memcpy(assrt_tlv->key_id, key_id_tlv->val, key_id_tlv->len); + assrt_tlv->key_id = (unsigned char*)calloc(1, key_id_tlv->len); + memcpy(assrt_tlv->key_id, key_id_tlv->val, key_id_tlv->len); - assrt_tlv->key_id_len = key_id_tlv->len; + assrt_tlv->key_id_len = key_id_tlv->len; - _INFO("key_id len = [%d]", key_id_tlv->len); + _INFO("key_id len = [%d]", key_id_tlv->len); - _free_tlv(key_id_tlv); - } + _free_tlv(key_id_tlv); + } - _INFO("Found TAG_KEYID"); - return assrt_tlv; - } - } + _INFO("Found TAG_KEYID"); + return assrt_tlv; + } + } - return NULL; + return NULL; } diff --git a/common/fido_uaf_utils.c b/common/fido_uaf_utils.c index 6aa5769..6a2ebf5 100644 --- a/common/fido_uaf_utils.c +++ b/common/fido_uaf_utils.c @@ -168,7 +168,7 @@ _free_message(_message_t *data) default: SAFE_DELETE(data->data); - } + } SAFE_DELETE(data); _INFO(""); @@ -521,7 +521,7 @@ _free_asm_out(_asm_out_t *data) _INFO("Freeing ext list"); g_list_free_full(data->ext_list, free); _INFO("After Freeing ext list"); - } + } SAFE_DELETE(data); _INFO(""); diff --git a/fido_svc_ui/fido_ui_server.c b/fido_svc_ui/fido_ui_server.c index 7064e50..2515b60 100644 --- a/fido_svc_ui/fido_ui_server.c +++ b/fido_svc_ui/fido_ui_server.c @@ -116,7 +116,7 @@ __init_dbus(void) { _INFO("init_dbus"); #if !GLIB_CHECK_VERSION(2, 35, 0) - g_type_init(); + g_type_init(); #endif GDBusConnection *connection = NULL; @@ -219,7 +219,7 @@ _create_json_response(ui_data_s *selected_auth) _INFO("_create_json_response end"); return json; - } + } g_object_unref(gen); @@ -272,7 +272,7 @@ _create_json_response(ui_data_s *selected_auth) _INFO("_create_json_response end"); return json; - } + } CATCH: if (generator != NULL) { @@ -363,7 +363,7 @@ _auth_arr_cb(JsonArray *array, guint index, JsonNode *element_node, gpointer use if (!obj) { _ERR("json_node_get_object() failed"); return; - } + } ui_data_s *ui_data = (ui_data_s *) calloc(1, sizeof(ui_data_s)); if (!ui_data) { @@ -377,7 +377,7 @@ _auth_arr_cb(JsonArray *array, guint index, JsonNode *element_node, gpointer use __free_ui_data(ui_data); return; - } + } const char *auth_idx = NULL; auth_idx = json_object_get_string_member(obj, UI_DATA_AUTH_INDEX); diff --git a/server/fido_app_id_handler.c b/server/fido_app_id_handler.c index 749b030..58a9f5c 100644 --- a/server/fido_app_id_handler.c +++ b/server/fido_app_id_handler.c @@ -146,21 +146,21 @@ __get_appid_of_dbus_caller(GDBusMethodInvocation *invocation) static void __soup_cb(SoupSession *session, SoupMessage *msg, gpointer user_data) { - _INFO("__soup_cb"); + _INFO("__soup_cb"); - if (user_data == NULL) - return; + if (user_data == NULL) + return; - _app_id_cb_data_t *cb_data = (_app_id_cb_data_t*)user_data; + _app_id_cb_data_t *cb_data = (_app_id_cb_data_t*)user_data; - GList *app_id_list = NULL; - char *real_app_id = NULL; + GList *app_id_list = NULL; + char *real_app_id = NULL; - int error_code = FIDO_ERROR_UNTRUSTED_FACET_ID; + int error_code = FIDO_ERROR_UNTRUSTED_FACET_ID; - SoupBuffer *request = NULL; + SoupBuffer *request = NULL; - _INFO("status_code = [%d]", msg->status_code); + _INFO("status_code = [%d]", msg->status_code); CATCH_IF_FAIL_X(msg->status_code == SOUP_STATUS_OK, error_code = FIDO_ERROR_UNTRUSTED_FACET_ID); diff --git a/server/fido_asm_plugin_manager.c b/server/fido_asm_plugin_manager.c index f4caab8..d8e2e58 100644 --- a/server/fido_asm_plugin_manager.c +++ b/server/fido_asm_plugin_manager.c @@ -472,6 +472,6 @@ _asm_ipc_send_sync(const char *asm_id, const char *asm_req) //g_variant_unref (_ret); -CATCH: +CATCH : return asm_res_json; } diff --git a/server/fido_privilege_checker.c b/server/fido_privilege_checker.c index 620e1cc..d6e88d2 100644 --- a/server/fido_privilege_checker.c +++ b/server/fido_privilege_checker.c @@ -78,18 +78,18 @@ __check_privilege_by_cynara(const char *client, const char *session, const char ret = cynara_check(__cynara, client, session, user, privilege); switch (ret) { - case CYNARA_API_ACCESS_ALLOWED: - _DBG("cynara_check success"); - return FIDO_ERROR_NONE; - - case CYNARA_API_ACCESS_DENIED: - _ERR("cynara_check permission deined, privilege=%s, error = CYNARA_API_ACCESS_DENIED", privilege); - return FIDO_ERROR_PERMISSION_DENIED; - - default: - cynara_strerror(ret, err_buf, sizeof(err_buf)); - _ERR("cynara_check error : %s, privilege=%s, ret = %d", err_buf, privilege, ret); - return FIDO_ERROR_PERMISSION_DENIED; + case CYNARA_API_ACCESS_ALLOWED: + _DBG("cynara_check success"); + return FIDO_ERROR_NONE; + + case CYNARA_API_ACCESS_DENIED: + _ERR("cynara_check permission deined, privilege=%s, error = CYNARA_API_ACCESS_DENIED", privilege); + return FIDO_ERROR_PERMISSION_DENIED; + + default: + cynara_strerror(ret, err_buf, sizeof(err_buf)); + _ERR("cynara_check error : %s, privilege=%s, ret = %d", err_buf, privilege, ret); + return FIDO_ERROR_PERMISSION_DENIED; } return FIDO_ERROR_NONE; diff --git a/server/fido_selection_ui_adaptor.c b/server/fido_selection_ui_adaptor.c index 71c5c69..4c4e1fd 100644 --- a/server/fido_selection_ui_adaptor.c +++ b/server/fido_selection_ui_adaptor.c @@ -448,9 +448,9 @@ __get_proc_path_of_dbus_caller(GDBusMethodInvocation *invocation) snprintf(buf, sizeof(buf), "/proc/%d/cmdline", upid); ret = __read_proc(buf, buf, sizeof(buf)); if (ret <= 0) { - _ERR("No proc directory (%d)\n", upid); - return NULL; - } + _ERR("No proc directory (%d)\n", upid); + return NULL; + } _INFO("Caller=[%s]", buf); diff --git a/server/fido_server.c b/server/fido_server.c index a337c1a..fa7285b 100755 --- a/server/fido_server.c +++ b/server/fido_server.c @@ -1268,7 +1268,7 @@ on_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_da G_CALLBACK(_dbus_on_fido_discover), NULL); g_signal_connect(fido_dbus_obj, "handle_fido_uaf_check_policy", - G_CALLBACK(_dbus_on_fido_uaf_is_supported), NULL); + G_CALLBACK(_dbus_on_fido_uaf_is_supported), NULL); g_signal_connect(fido_dbus_obj, "handle_fido_uaf_process_operation", G_CALLBACK(_dbus_on_fido_process_operation), NULL); diff --git a/server/fido_uaf_policy_checker.c b/server/fido_uaf_policy_checker.c index f3bf758..7d1c3f6 100644 --- a/server/fido_uaf_policy_checker.c +++ b/server/fido_uaf_policy_checker.c @@ -150,8 +150,7 @@ _policy_checker_is_matched(_match_criteria_t *match_criteria, fido_authenticator && ((match_criteria->user_verification & _USER_VER_METHOD_ALL) == 0) && - ((auth_info->user_verification & match_criteria->user_verification) != 0))) - { + ((auth_info->user_verification & match_criteria->user_verification) != 0))) { _INFO("User verification match passed"); } else { _ERR("User verification match failed"); @@ -283,53 +282,53 @@ __get_verification_method_string(unsigned long int ver_method) switch (ver_method) { - case _USER_VER_METHOD_PRESENCE: - snprintf(ver_str, 127, "%s", "Presence Authenticator"); - break; + case _USER_VER_METHOD_PRESENCE: + snprintf(ver_str, 127, "%s", "Presence Authenticator"); + break; - case _USER_VER_METHOD_FINGERPRINT: - snprintf(ver_str, 127, "%s", "Fingerprint Authenticator"); - break; + case _USER_VER_METHOD_FINGERPRINT: + snprintf(ver_str, 127, "%s", "Fingerprint Authenticator"); + break; - case _USER_VER_METHOD_PASSCODE: - snprintf(ver_str, 127, "%s", "Passcode Authenticator"); - break; + case _USER_VER_METHOD_PASSCODE: + snprintf(ver_str, 127, "%s", "Passcode Authenticator"); + break; - case _USER_VER_METHOD_VOICE_PRINT: - snprintf(ver_str, 127, "%s", "Voice Print Authenticator"); - break; + case _USER_VER_METHOD_VOICE_PRINT: + snprintf(ver_str, 127, "%s", "Voice Print Authenticator"); + break; - case _USER_VER_METHOD_FACE_PRINT: - snprintf(ver_str, 127, "%s", "Face Print Authenticator"); - break; + case _USER_VER_METHOD_FACE_PRINT: + snprintf(ver_str, 127, "%s", "Face Print Authenticator"); + break; - case _USER_VER_METHOD_LOCATION: - snprintf(ver_str, 127, "%s", "Location Authenticator"); - break; + case _USER_VER_METHOD_LOCATION: + snprintf(ver_str, 127, "%s", "Location Authenticator"); + break; - case _USER_VER_METHOD_EYE_PRINT: - snprintf(ver_str, 127, "%s", "Eye Print Authenticator"); - break; + case _USER_VER_METHOD_EYE_PRINT: + snprintf(ver_str, 127, "%s", "Eye Print Authenticator"); + break; - case _USER_VER_METHOD_PATTERN: - snprintf(ver_str, 127, "%s", "Pattern Authenticator"); - break; + case _USER_VER_METHOD_PATTERN: + snprintf(ver_str, 127, "%s", "Pattern Authenticator"); + break; - case _USER_VER_METHOD_HAND_PRINT: - snprintf(ver_str, 127, "%s", "Hand Print Authenticator"); - break; + case _USER_VER_METHOD_HAND_PRINT: + snprintf(ver_str, 127, "%s", "Hand Print Authenticator"); + break; - // case _USER_VER_METHOD_NONE: - // snprintf(ver_str, "%s", ""); - // break; +// case _USER_VER_METHOD_NONE: +// snprintf(ver_str, "%s", ""); +// break; - case _USER_VER_METHOD_ALL: - snprintf(ver_str, 127, "%s", "All Authenticator"); - break; + case _USER_VER_METHOD_ALL: + snprintf(ver_str, 127, "%s", "All Authenticator"); + break; - default: - snprintf(ver_str, 127, "%s", "Other Type"); - break; + default: + snprintf(ver_str, 127, "%s", "Other Type"); + break; } return ver_str; diff --git a/test/FIDOSample/src/main.c b/test/FIDOSample/src/main.c index abfa3aa..7691096 100755 --- a/test/FIDOSample/src/main.c +++ b/test/FIDOSample/src/main.c @@ -31,32 +31,32 @@ static char *json_dereg = NULL; static char* __read(const char *file_name) { - FILE *file = fopen(file_name, "rb"); - if (file == NULL) - return NULL; - - fseek(file, 0, SEEK_END); - long size = ftell(file); - if (size <= 0) { - fclose(file); - return NULL; - } + FILE *file = fopen(file_name, "rb"); + if (file == NULL) + return NULL; + + fseek(file, 0, SEEK_END); + long size = ftell(file); + if (size <= 0) { + fclose(file); + return NULL; + } - fseek(file, 0, SEEK_SET); + fseek(file, 0, SEEK_SET); - char *json = calloc(1, size + 1); - int num_bytes = fread(json, size, 1, file); - if (num_bytes <= 0) { - free(json); - fclose(file); - return NULL; - } + char *json = calloc(1, size + 1); + int num_bytes = fread(json, size, 1, file); + if (num_bytes <= 0) { + free(json); + fclose(file); + return NULL; + } - json[size] = 0; + json[size] = 0; - fclose(file); + fclose(file); - return json; + return json; } @@ -277,7 +277,7 @@ __print_discovery_data(fido_discovery_data_h discovery_data, appdata_s *ad) int ret = fido_discovery_data_foreach_authenticator(discovery_data, auth_list_cb, ad); dlog_print(DLOG_INFO, "org.tizen.Fidosample", "fido_discovery_data_foreach_authenticator =[%d]", ret); - fido_discovery_data_destroy(discovery_data); + fido_discovery_data_destroy(discovery_data); } static void @@ -408,7 +408,7 @@ _process_cb_for_notify_pos(int tizen_error_code, char *uaf_response, void *user_ dlog_print(DLOG_INFO, "org.tizen.Fidosample", "uaf response = %s", uaf_response); int ret = fido_request_set_result(FIDO_SERVER_STATUS_CODE_OK, uaf_response); - dlog_print(DLOG_INFO, "org.tizen.Fidosample", "fido_request_set_result =[%d]", ret); + dlog_print(DLOG_INFO, "org.tizen.Fidosample", "fido_request_set_result =[%d]", ret); char *error_string = get_error_code(tizen_error_code); create_popup(error_string, (appdata_s *) user_data); @@ -429,7 +429,7 @@ _process_cb_for_notify_neg(int tizen_error_code, char *uaf_response, void *user_ dlog_print(DLOG_INFO, "org.tizen.Fidosample", "uaf response = %s", uaf_response); int ret = fido_request_set_result(0, uaf_response); - dlog_print(DLOG_INFO, "org.tizen.Fidosample", "fido_request_set_result =[%d]", ret); + dlog_print(DLOG_INFO, "org.tizen.Fidosample", "fido_request_set_result =[%d]", ret); char *error_string = get_error_code(tizen_error_code); create_popup(error_string, (appdata_s *) user_data); diff --git a/test/Fido_Sample_RPM/src/main.c b/test/Fido_Sample_RPM/src/main.c index cd86ca0..21e2139 100755 --- a/test/Fido_Sample_RPM/src/main.c +++ b/test/Fido_Sample_RPM/src/main.c @@ -296,7 +296,7 @@ start_check_policy(void *data, Evas_Object *obj, void *event_info) static void _process_cb(fido_error_e tizen_error_code, const char *uaf_response, void *user_data) { - dlog_print(DLOG_INFO, "org.tizen.Fidosample", "process response = [%d]", tizen_error_code); + dlog_print(DLOG_INFO, "org.tizen.Fidosample", "process response = [%d]", tizen_error_code); if (tizen_error_code == 0 && uaf_response != NULL) { dlog_print(DLOG_INFO, "org.tizen.Fidosample", "uaf response = %s", uaf_response); @@ -372,7 +372,7 @@ _process_cb_for_notify_pos(fido_error_e tizen_error_code, const char *uaf_respon dlog_print(DLOG_INFO, "org.tizen.Fidosample", "uaf response = %s", uaf_response); int ret = fido_uaf_set_server_result(FIDO_SERVER_STATUS_CODE_OK, uaf_response); - dlog_print(DLOG_INFO, "org.tizen.Fidosample", "fido_uaf_set_server_result =[%d]", ret); + dlog_print(DLOG_INFO, "org.tizen.Fidosample", "fido_uaf_set_server_result =[%d]", ret); char *error_string = get_error_code(tizen_error_code); create_popup(error_string, (appdata_s *) user_data); @@ -385,13 +385,13 @@ _process_cb_for_notify_pos(fido_error_e tizen_error_code, const char *uaf_respon static void _process_cb_for_notify_neg(fido_error_e tizen_error_code, const char *uaf_response, void *user_data) { - dlog_print(DLOG_INFO, "org.tizen.Fidosample", "process response = [%d]", tizen_error_code); + dlog_print(DLOG_INFO, "org.tizen.Fidosample", "process response = [%d]", tizen_error_code); if (tizen_error_code == 0) { dlog_print(DLOG_INFO, "org.tizen.Fidosample", "uaf response = %s", uaf_response); int ret = fido_uaf_set_server_result(0, uaf_response); - dlog_print(DLOG_INFO, "org.tizen.Fidosample", "fido_uaf_set_server_result =[%d]", ret); + dlog_print(DLOG_INFO, "org.tizen.Fidosample", "fido_uaf_set_server_result =[%d]", ret); char *error_string = get_error_code(tizen_error_code); create_popup(error_string, (appdata_s *) user_data); diff --git a/test/shell_tc/fido_shell_tc.c b/test/shell_tc/fido_shell_tc.c index a30e46f..7546d6a 100644 --- a/test/shell_tc/fido_shell_tc.c +++ b/test/shell_tc/fido_shell_tc.c @@ -416,6 +416,6 @@ main(void) get_user_choice(); g_main_loop_run(mainloop); - + return 0; } diff --git a/test/shell_tc/fido_shell_tc_util.c b/test/shell_tc/fido_shell_tc_util.c index c76ecf0..060b5ae 100644 --- a/test/shell_tc/fido_shell_tc_util.c +++ b/test/shell_tc/fido_shell_tc_util.c @@ -22,7 +22,7 @@ #include void - print_fail_result( +print_fail_result( const char *action_name, int action_return_value) { -- 2.7.4