Fix wrong hash management 75/181775/1
authorjusung son <jusung07.son@samsung.com>
Mon, 18 Jun 2018 07:36:13 +0000 (16:36 +0900)
committerjusung son <jusung07.son@samsung.com>
Mon, 18 Jun 2018 07:36:13 +0000 (16:36 +0900)
 - A value managed by dbus was used as hash key. So the registered hash key is deleted by dbus

Change-Id: If26359e031f6d1a7f783208446f8badb81633baf
Signed-off-by: jusung son <jusung07.son@samsung.com>
src/message_port_remote.c

index da0a6fe..e6aaeab 100755 (executable)
@@ -562,6 +562,7 @@ static bool __receive_message(GVariant *parameters, GDBusMethodInvocation *invoc
        int *returned_fds = NULL;
        int fd;
        bool ret = false;
+       char *key_appid;
 
        g_variant_get(parameters, "(&s&sbb&s&sbu&s)", &local_appid, &local_port, &local_trusted, &bi_dir,
                        &remote_appid, &remote_port, &remote_trusted, &len, &raw);
@@ -614,9 +615,11 @@ static bool __receive_message(GVariant *parameters, GDBusMethodInvocation *invoc
                if (g_hash_table_lookup(__trusted_app_list_hash, (gpointer)local_appid) == NULL) {
                        if (!is_preloaded(local_appid, remote_appid)) {
                                int ret = check_certificate(local_appid, remote_appid);
-                               if (ret == MESSAGE_PORT_ERROR_NONE)
-                                       g_hash_table_insert(__trusted_app_list_hash, local_appid, "TRUE");
-                               else {
+                               if (ret == MESSAGE_PORT_ERROR_NONE) {
+                                       key_appid = strdup(local_appid);
+                                       if (key_appid)
+                                               g_hash_table_insert(__trusted_app_list_hash, key_appid, "TRUE");
+                               } else {
                                        _LOGE("The application (%s) is not signed with the same certificate",
                                                        local_appid);
                                        goto out;