Check if request is valid to avoid crash 59/186759/1 accepted/tizen/unified/20180816.062923 submit/tizen/20180814.072508
authorchleun.moon <chleun.moon@samsung.com>
Tue, 14 Aug 2018 06:41:56 +0000 (15:41 +0900)
committerchleun.moon <chleun.moon@samsung.com>
Tue, 14 Aug 2018 06:42:01 +0000 (15:42 +0900)
Change-Id: Ic9bb064bbab2bb1386c9aad10a9e7899caddd98f
Signed-off-by: Cheoleun Moon <chleun.moon@samsung.com>
agent/download-agent-http-mgr.c
packaging/download-provider.spec
provider/download-provider-plugin-download-agent.c

index fd6874f..6bf449f 100755 (executable)
@@ -441,7 +441,7 @@ da_ret_t request_http_download(da_info_t *da_info)
        da_ret_t ret = DA_RESULT_OK;
        req_info_t *req_info = DA_NULL;
        http_info_t *http_info = DA_NULL;
-       http_state_t http_state = 0;
+       http_state_t http_state = HTTP_STATE_READY_TO_DOWNLOAD;
        da_bool_t need_wait = DA_TRUE;
 
        DA_LOGV("");
index 098be4d..29c3d17 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       download-provider
 Summary:    Download the contents in background
-Version:    2.1.100
+Version:    2.1.101
 Release:    0
 Group:      Development/Libraries
 License:    Apache-2.0
index d13a34b..aea7966 100755 (executable)
@@ -178,24 +178,26 @@ static int __dp_da_state_feedback(dp_client_slots_fmt *slot, dp_request_fmt *req
        return 0;
 }
 
-static int __precheck_request(dp_request_fmt *request, int agentid)
+static int __precheck_request(dp_client_slots_fmt* slot, dp_request_fmt *request, int agentid)
 {
        if (request == NULL) {
                TRACE_ERROR("null-check req_id:%d", agentid);
                return -1;
        }
 
-       if (dp_is_alive_download(agentid) == 0) {
-               TRACE_ERROR("alive-check req_id:%d", agentid);
-               return -1;
-       }
+       dp_client_fmt *client = &slot->client;
 
-       if (request->id < 0 || (request->agent_id != agentid)) {
-               TRACE_ERROR("id-check request_id:%d agent_id:%d req_id:%d",
-                               request->id, request->agent_id, agentid);
-               return -1;
+       for (dp_request_fmt *req = client->requests; req; req = req->next) {
+               if (req == request) {
+                       if (request->id < 0 || (request->agent_id != agentid)) {
+                               TRACE_ERROR("id-check request_id:%d agent_id:%d req_id:%d",
+                                               request->id, request->agent_id, agentid);
+                               return -1;
+                       }
+                       return 0;
+               }
        }
-       return 0;
+       return -1;
 }
 
 static int __set_file_permission_to_client(dp_client_slots_fmt *slot, dp_request_fmt *request, char *saved_path)
@@ -265,7 +267,7 @@ static void __finished_cb(finished_info_t *info, void *user_req_data,
                return ;
        }
        CLIENT_MUTEX_LOCK(&slot->mutex);
-       if (__precheck_request(request, info->download_id) < 0) {
+       if (__precheck_request(slot, request, info->download_id) < 0) {
                TRACE_ERROR("error request agent_id:%d", info->download_id);
                if (dp_cancel_agent_download(info->download_id) < 0)
                        TRACE_ERROR("failed to call cancel_download(%d)", info->download_id);
@@ -401,7 +403,7 @@ static void __download_info_cb(download_info_t *info, void *user_req_data, void
                return ;
        }
        CLIENT_MUTEX_LOCK(&slot->mutex);
-       if (__precheck_request(request, info->download_id) < 0) {
+       if (__precheck_request(slot, request, info->download_id) < 0) {
                TRACE_ERROR("error request agent_id:%d", info->download_id);
                if (dp_cancel_agent_download(info->download_id) < 0)
                        TRACE_ERROR("failed to call cancel_download(%d)", info->download_id);
@@ -486,7 +488,7 @@ static void __progress_cb(int download_id, unsigned long long received_size,
           return ;
           }
           */
-       if (__precheck_request(request, download_id) < 0) {
+       if (__precheck_request(slot, request, download_id) < 0) {
                TRACE_ERROR("error request agent_id:%d", download_id);
                if (dp_cancel_agent_download(download_id) < 0)
                        TRACE_ERROR("failed to call cancel_download(%d)", download_id);