From ab6eea1d06a25faed6f657e71cbe56c4323c14a1 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 23 Jul 2013 16:09:47 +0800 Subject: [PATCH] Fix: coredump if invoke pthread_* with NULL thread handler This coredump can be triggered if download-provider request the well-known dbus name failed, for example, currently, there is no dbus policy conf for download-provider, so dbus daemon will reject its request. Bug: https://bugs.tizen.org/jira/browse/TDIST-276 Change-Id: Id341aa7da19bc89085bd5909391a37dde19b0173 Signed-off-by: Chengwei Yang --- agent/download-agent-client-mgr.c | 7 ++++--- packaging/download-provider.spec | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/agent/download-agent-client-mgr.c b/agent/download-agent-client-mgr.c index e4268ac..a19e3ba 100755 --- a/agent/download-agent-client-mgr.c +++ b/agent/download-agent-client-mgr.c @@ -44,6 +44,7 @@ da_result_t init_client_app_mgr() client_app_mgr.is_init = DA_TRUE; client_app_mgr.client_app_info.client_user_agent = DA_NULL; client_app_mgr.is_thread_init = DA_FALSE; + client_app_mgr.thread_id = 0; return DA_RESULT_OK; } @@ -104,7 +105,7 @@ da_result_t dereg_client_app(void) _da_thread_mutex_lock(&(client_app_mgr.mutex_client_mgr)); if (client_app_mgr.is_thread_init != DA_TRUE) { DA_LOG_CRITICAL(ClientNoti, "try to cancel client mgr thread id[%lu]", client_app_mgr.thread_id); - if (pthread_cancel(client_app_mgr.thread_id) < 0) { + if (client_app_mgr.thread_id && pthread_cancel(client_app_mgr.thread_id) < 0) { DA_LOG_ERR(ClientNoti, "cancel thread is failed!!!"); } free(client_noti); @@ -113,7 +114,7 @@ da_result_t dereg_client_app(void) DA_LOG_VERBOSE(ClientNoti, "pushing Q_CLIENT_NOTI_TYPE_TERMINATE"); push_client_noti(client_noti); DA_LOG_CRITICAL(Thread, "===try to join client mgr thread id[%lu]===", client_app_mgr.thread_id); - if (pthread_join(client_app_mgr.thread_id, &t_return) < 0) { + if (client_app_mgr.thread_id && pthread_join(client_app_mgr.thread_id, &t_return) < 0) { DA_LOG_ERR(Thread, "join client thread is failed!!!"); } DA_LOG_CRITICAL(Thread, "===thread join return[%d]===", (char*)t_return); @@ -332,7 +333,7 @@ da_result_t send_client_finished_info ( da_result_t __launch_client_thread(void) { - pthread_t thread_id = DA_NULL; + pthread_t thread_id = 0; DA_LOG_FUNC_START(Thread); diff --git a/packaging/download-provider.spec b/packaging/download-provider.spec index a07c0bc..40437f7 100755 --- a/packaging/download-provider.spec +++ b/packaging/download-provider.spec @@ -2,7 +2,7 @@ Name: download-provider Summary: Download the contents in background Version: 1.0.5 -Release: 9 +Release: 10 Group: Development/Libraries License: Apache License, Version 2.0 Source0: %{name}-%{version}.tar.gz -- 2.7.4