Check request ID before updating download information 59/185859/2
authorSeonah Moon <seonah1.moon@samsung.com>
Fri, 3 Aug 2018 05:13:20 +0000 (14:13 +0900)
committerseonah moon <seonah1.moon@samsung.com>
Fri, 3 Aug 2018 08:33:14 +0000 (08:33 +0000)
downaload thread often accesses to memory which is freed by other thread.
To avoid refering invalid memory, this patch checks whether request ID is
valid or not.

Change-Id: I994bcf73714c2af3d896b07f27534ae8580c0545

provider/download-provider-plugin-download-agent.c

index 8becb2e..d13a34b 100755 (executable)
@@ -181,9 +181,15 @@ static int __dp_da_state_feedback(dp_client_slots_fmt *slot, dp_request_fmt *req
 static int __precheck_request(dp_request_fmt *request, int agentid)
 {
        if (request == NULL) {
-               TRACE_ERROR("null-check request req_id:%d", agentid);
+               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;
+       }
+
        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);