coverity fixes 11/196811/1 accepted/tizen_4.0_unified accepted/tizen/4.0/unified/20190107.145018 submit/tizen_4.0/20190104.101828
authorAbhishek Vijay <abhishek.v@samsung.com>
Fri, 4 Jan 2019 10:12:09 +0000 (15:42 +0530)
committerAbhishek Vijay <abhishek.v@samsung.com>
Fri, 4 Jan 2019 10:12:09 +0000 (15:42 +0530)
Change-Id: I5642b7a4da6697921ff7e3f4082d6066eecc49d5
Signed-off-by: Abhishek Vijay <abhishek.v@samsung.com>
common/fido_json_handler.c
doc/fido_doc.h
server/fido_app_id_handler.c
server/fido_selection_ui_adaptor.c
test/Dummy_ASM_DBUS/dummy_asm_server.c

index 98ade9f..6616167 100755 (executable)
@@ -479,9 +479,13 @@ __get_string_from_json_object(JsonObject *obj, const char *key)
                return NULL;
 
        const char *str = json_object_get_string_member(obj, key);
-       _INFO("[%s] = [%s]", key, str);
-
-       return strdup(str);
+       _INFO("[%s] ", key);
+       if (str != NULL) {
+               _INFO("[%s] ", str);
+               return strdup(str);
+       } else {
+               return NULL;
+       }
 }
 
 static int
@@ -1902,14 +1906,22 @@ _uaf_composer_compose_final_challenge(const char *app_id, const char *challenge,
 
                GError *chb_err = NULL;
                bool chb_parsed = json_parser_load_from_data(chb_parser, ch_bin, -1, &chb_err);
-               if (chb_parsed == FALSE)
+               if (chb_parsed == FALSE) {
+                       g_object_unref(builder);
                        return NULL;
+               }
 
                JsonNode *chb_root = json_parser_get_root(chb_parser);
-               RET_IF_FAIL(chb_root != NULL, NULL);
+               if (chb_root == NULL) {
+                       g_object_unref(builder);
+                       return NULL;
+               }
 
                JsonObject *chb_root_obj = json_node_get_object(chb_root);
-               RET_IF_FAIL(chb_root_obj != NULL, NULL);
+               if (chb_root_obj == NULL) {
+                       g_object_unref(builder);
+                       return NULL;
+               }
 
                char *end_pt = __get_string_from_json_object(chb_root_obj, _JSON_KEY_SERVER_END_POINT);
                char *cert = __get_string_from_json_object(chb_root_obj, _JSON_KEY_TLS_SERVER_CERT);
@@ -2498,7 +2510,7 @@ _uaf_composer_compose_dereg_request(_response_t *uaf_res)
 
 
                assertions_iter = assertions_iter->next;
-
+               SAFE_DELETE(aaid);
        }
 
        json_builder_end_array(auth_root);
index 8ac58d9..da37a27 100755 (executable)
  *
  * @defgroup  CAPI_FIDO_UAF_MESSAGES_MODULE FIDO UAF MESSAGES
  * @ingroup   CAPI_FIDO_MODULE
- * @brief     Fido UAF Messasges
+ * @brief     Fido UAF Messages
  *
  * @section   CAPI_FIDO_UAF_CLIENT_HEADER Required Header
  *  \#include <fido_uaf_client.h>
  *
  * @section CAPI_FIDO_REQUESTS_MODULE_OVERVIEW Overview
- * The FIDO UAF Client APIs which process UAF meesages from fido server.
+ * The FIDO UAF Client APIs which process UAF messages from fido server.
  * More details about the FIDO specification can be found in https://fidoalliance.org/specifications/download
  *
  * @defgroup  CAPI_FIDO_AUTHENTICATOR_MODULE FIDO AUTHENTICATOR
index d6684e0..c9cf93a 100755 (executable)
@@ -209,10 +209,16 @@ __get_pub_key(const char *json_id_str)
        RET_IF_FAIL(json_id_str != NULL, NULL);
 
 
-       char *save_ptr;
-       char *os = strtok_r(strdup(json_id_str), ":", &save_ptr);
+       char *save_ptr = NULL, *tempStr = NULL;
+       tempStr = strdup(json_id_str);
+       RET_IF_FAIL(json_id_str != NULL, NULL);
+
+       char *os = strtok_r(tempStr, ":", &save_ptr);
 
-       RET_IF_FAIL(os != NULL, NULL);
+       if (os == NULL) {
+               free(tempStr);
+               return NULL;
+       }
 
        if (strcmp(os, FIDO_APP_ID_KEY_TIZEN) != 0) {
                _ERR("[%s] is not supported", os);
@@ -220,7 +226,10 @@ __get_pub_key(const char *json_id_str)
        }
 
        char *type = strtok_r(NULL, ":", &save_ptr);
-       RET_IF_FAIL(type != NULL, NULL);
+
+       if (type == NULL) {
+               return NULL;
+       }
 
        if (strcmp(type, FIDO_APP_ID_KEY_PKG_HASH) != 0) {
                _ERR("[%s] is not supported", type);
@@ -568,7 +577,7 @@ __get_tz_facet_id_of_caller(const char *caller_app_id, GDBusMethodInvocation *in
        tz_facet_id = (char*)(calloc(1, tz_facet_id_max_len));
        snprintf(tz_facet_id, tz_facet_id_max_len, "%s:%s", "tizen:pkg-key-hash",
                         author_cert_hash);
-
+       SAFE_DELETE(author_cert_hash);
 CATCH:
        pkgmgrinfo_pkginfo_destroy_certinfo(cert_handle);
        pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
index 9bb5879..c35bdfc 100755 (executable)
@@ -480,6 +480,7 @@ _auth_ui_selector_on_ui_response(Fido *object, GDBusMethodInvocation *invocation
        if (strcmp(caller, _UI_SVC_BIN_PATH) != 0) {
                _ERR("[%s] is not allowed", caller);
                __start_ui_svc_term_timer();
+               free(caller);
                return true;
        }
 
index ad87871..97039a6 100755 (executable)
@@ -159,9 +159,11 @@ __get_request_type(const char *asm_req_json)
        JsonObject *root_obj = json_node_get_object(root);
 
        const char *req_type = json_object_get_string_member(root_obj, "requestType");
-
-       return strdup(req_type);
-
+       if (req_type != NULL) {
+               return strdup(req_type);
+       } else {
+               return NULL;
+       }
 }
 
 gboolean
@@ -179,12 +181,14 @@ _dbus_on_asm_request(Dummyasm *object, GDBusMethodInvocation *invocation, const
        if (strcmp(caller_path, _FIDO_SERVICE_PATH) != 0) {
                _ERR("Only fido-service is allowed to call ASM");
                dummyasm_complete_asm_request(object, invocation, -1, NULL);
+               free(caller_path);
                return true;
        }
 
        char *req_type = __get_request_type(uaf_request_json);
        if (req_type == NULL) {
-                dummyasm_complete_asm_request(object, invocation, -1, NULL);
+               dummyasm_complete_asm_request(object, invocation, -1, NULL);
+               free(caller_path);
                return true;
        }
 
@@ -201,6 +205,8 @@ _dbus_on_asm_request(Dummyasm *object, GDBusMethodInvocation *invocation, const
        if (strcmp(req_type, "GetRegistrations") == 0)
                dummyasm_complete_asm_request(object, invocation, 0, _GET_REGISTRATIONS_RESPONSE);
 
+       free(req_type);
+       free(caller_path);
        return true;
 }