From 5d4df7d9e9327618dd21edaad59b43fe3b23d9f8 Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Thu, 24 Mar 2016 17:16:25 +0900 Subject: [PATCH] Fix svace issues for Tizen_3.0_TV_Prebeta replace thread unsafe function- strerror and change function call order Change-Id: I8d49b3df607788110538553af57c186df04ed52c --- src/common/gum-file.c | 6 +++++- src/daemon/dbus/gumd-dbus-group-service-adapter.c | 6 +++--- src/daemon/dbus/gumd-dbus-server-p2p.c | 8 ++++++-- src/daemon/dbus/gumd-dbus-user-service-adapter.c | 6 +++--- src/daemon/main.c | 20 +++++++++++++++++++- src/lib/gum-user-service.c | 2 +- 6 files changed, 37 insertions(+), 11 deletions(-) mode change 100644 => 100755 src/common/gum-file.c mode change 100644 => 100755 src/daemon/dbus/gumd-dbus-server-p2p.c mode change 100644 => 100755 src/daemon/main.c mode change 100644 => 100755 src/lib/gum-user-service.c diff --git a/src/common/gum-file.c b/src/common/gum-file.c old mode 100644 new mode 100755 index d6f424a..fc071c2 --- a/src/common/gum-file.c +++ b/src/common/gum-file.c @@ -107,6 +107,7 @@ */ #define GUM_PERM 0777 +#define MAX_STRERROR_LEN 256 static gboolean _set_smack64_attr ( @@ -146,7 +147,10 @@ _open_file ( FILE *fp = NULL; if (!fn || !(fp = fopen (fn, mode))) { if (!fp) - WARN ("Could not open file '%s', error: %s", fn, strerror(errno)); + { + char buf[MAX_STRERROR_LEN];; + WARN ("Could not open file '%s', error: %s", fn, strerror_r(errno, buf, MAX_STRERROR_LEN)); + } return NULL; } return fp; diff --git a/src/daemon/dbus/gumd-dbus-group-service-adapter.c b/src/daemon/dbus/gumd-dbus-group-service-adapter.c index 4c734d7..cc4a9c8 100644 --- a/src/daemon/dbus/gumd-dbus-group-service-adapter.c +++ b/src/daemon/dbus/gumd-dbus-group-service-adapter.c @@ -218,9 +218,9 @@ _dbus_peer_group_remove ( if (peer_group && GUMD_IS_DBUS_GROUP_ADAPTER(peer_group->dbus_group)) { g_object_weak_unref (G_OBJECT (peer_group->dbus_group), _on_dbus_group_adapter_disposed, group_data); - _dbus_peer_group_free (peer_group, NULL); self->priv->peer_groups = g_list_remove (self->priv->peer_groups, (gpointer)peer_group); + _dbus_peer_group_free (peer_group, NULL); } } @@ -355,10 +355,10 @@ _clear_cache_for_peer_name ( DBG ("removing dbus group '%p' from cache", peer_group->dbus_group); g_object_weak_unref (G_OBJECT (peer_group->dbus_group), _on_dbus_group_adapter_disposed, peer_group->group_service); - _dbus_peer_group_free (peer_group, NULL); group_data->group_service->priv->peer_groups = g_list_remove ( group_data->group_service->priv->peer_groups, (gpointer)peer_group); + _dbus_peer_group_free (peer_group, NULL); } } @@ -418,10 +418,10 @@ _clear_cache_for_group ( if (peer_group->dbus_group == group_data->dbus_group) { DBG ("removing dbus group '%p' from cache", peer_group->dbus_group); peer_group->dbus_group = NULL; - _dbus_peer_group_free (peer_group, NULL); group_data->group_service->priv->peer_groups = g_list_remove ( group_data->group_service->priv->peer_groups, (gpointer)peer_group); + _dbus_peer_group_free (peer_group, NULL); } } diff --git a/src/daemon/dbus/gumd-dbus-server-p2p.c b/src/daemon/dbus/gumd-dbus-server-p2p.c old mode 100644 new mode 100755 index b0efc4d..ad386c7 --- a/src/daemon/dbus/gumd-dbus-server-p2p.c +++ b/src/daemon/dbus/gumd-dbus-server-p2p.c @@ -85,6 +85,8 @@ G_DEFINE_TYPE_WITH_CODE (GumdDbusServerP2P, #define GUMD_DBUS_SERVER_P2P_GET_PRIV(obj) G_TYPE_INSTANCE_GET_PRIVATE ((obj),\ GUMD_TYPE_DBUS_SERVER_P2P, GumdDbusServerP2PPrivate) +#define MAX_STRERROR_LEN 256 + static void _set_property ( GObject *object, @@ -394,8 +396,9 @@ _gumd_dbus_server_p2p_start ( path = g_strstr_len(server->priv->address, -1, "unix:path=") + 10; if (path) { if (g_chmod (path, S_IRUSR | S_IWUSR) < 0) { + gchar buf[MAX_STRERROR_LEN]; WARN("Setting server socket permission failed with error '%s'", - strerror(errno)); + strerror_r(errno, buf, MAX_STRERROR_LEN)); } } } @@ -493,8 +496,9 @@ gumd_dbus_server_p2p_new_with_address ( gchar *base_path = g_path_get_dirname (file_path); if (g_mkdir_with_parents (base_path, S_IRUSR | S_IWUSR | S_IXUSR) == -1) { + gchar buf[MAX_STRERROR_LEN]; WARN ("Could not create '%s', error: %s", base_path, - strerror(errno)); + strerror_r(errno, buf, MAX_STRERROR_LEN)); } g_free (base_path); } diff --git a/src/daemon/dbus/gumd-dbus-user-service-adapter.c b/src/daemon/dbus/gumd-dbus-user-service-adapter.c index 08708d9..9c15f89 100644 --- a/src/daemon/dbus/gumd-dbus-user-service-adapter.c +++ b/src/daemon/dbus/gumd-dbus-user-service-adapter.c @@ -224,9 +224,9 @@ _dbus_peer_user_remove ( if (peer_user && GUMD_IS_DBUS_USER_ADAPTER(peer_user->user_adapter)) { g_object_weak_unref (G_OBJECT (peer_user->user_adapter), _on_dbus_user_adapter_disposed, user_data); - _dbus_peer_user_free (peer_user, NULL); self->priv->peer_users = g_list_remove (self->priv->peer_users, (gpointer)peer_user); + _dbus_peer_user_free (peer_user, NULL); } } @@ -362,10 +362,10 @@ _clear_cache_for_peer_name ( peer_user->user_adapter, peer_user->peer_name); g_object_weak_unref (G_OBJECT (peer_user->user_adapter), _on_dbus_user_adapter_disposed, peer_user->user_service); - _dbus_peer_user_free (peer_user, NULL); user_data->user_service->priv->peer_users = g_list_remove ( user_data->user_service->priv->peer_users, (gpointer)peer_user); + _dbus_peer_user_free (peer_user, NULL); } } @@ -426,10 +426,10 @@ _clear_cache_for_user ( DBG ("removing dbus user adapter '%p' from cache", peer_user->user_adapter); peer_user->user_adapter = NULL; - _dbus_peer_user_free (peer_user, NULL); user_data->user_service->priv->peer_users = g_list_remove ( user_data->user_service->priv->peer_users, (gpointer)peer_user); + _dbus_peer_user_free (peer_user, NULL); } } diff --git a/src/daemon/main.c b/src/daemon/main.c old mode 100644 new mode 100755 index 0ac7791..78311e4 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -159,6 +159,12 @@ main (int argc, char **argv) gid_t daemon_gid; struct group *daemon_group = NULL; + struct group buf_group; + gchar *buf = NULL; + gchar *tmp = NULL; + gsize buflen = sysconf(_SC_GETGR_R_SIZE_MAX); + if (buflengr_gid; + + if (buf) + g_free(buf); + if (setegid (daemon_gid)) WARN ("setegid() failed"); DBG ("After set: r-gid %d e-gid %d", getgid (), getegid ()); diff --git a/src/lib/gum-user-service.c b/src/lib/gum-user-service.c old mode 100644 new mode 100755 index 09fde3b..d46c072 --- a/src/lib/gum-user-service.c +++ b/src/lib/gum-user-service.c @@ -298,7 +298,7 @@ static gboolean _service_dbus_proxy_callback ( gpointer user_data) { - g_return_if_fail (user_data && GUM_IS_USER_SERVICE (user_data)); + g_return_val_if_fail (user_data && GUM_IS_USER_SERVICE (user_data), FALSE); const gchar *env = NULL; GumDbusUserService *dbus_service = NULL; GDBusConnection *connection = NULL; -- 2.7.4