From: Veeraj Khokale Date: Fri, 6 Apr 2018 09:03:12 +0000 (+0530) Subject: Crash in OCProcessPresence() X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dd25af4e3cab568949686ee15f45b71ad87d6c0d;hp=bfaee3a677dad15779700d857e03618812ab2554;p=platform%2Fupstream%2Fiotivity.git Crash in OCProcessPresence() 1. Set presence to NULL incase allocation of timeout array fails. This ensures that OCProcessPresence does not process this cbNode, thereby preventing possible NULL dereference of timeout. 2. Do not send request if timeout has reached/exceeded the PresenceTimeOutSize. This prevents a possible buffer overrun in accessing the timeout array. https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/279 (cherry picked from commit 22079af2bd0f22a80b98c3b17469c3b8ed601ede) Change-Id: I6a16c6675236518c008a88c590264dedea698a3a Signed-off-by: Veeraj Khokale Signed-off-by: Amit KS --- diff --git a/resource/csdk/stack/src/ocstack.c b/resource/csdk/stack/src/ocstack.c index c34b2f2..60e8e29 100644 --- a/resource/csdk/stack/src/ocstack.c +++ b/resource/csdk/stack/src/ocstack.c @@ -1242,6 +1242,7 @@ OCStackResult HandlePresenceResponse(const CAEndpoint_t *endpoint, OIC_LOG(ERROR, TAG, "Could not allocate memory for cbNode->presence->timeOut"); OICFree(cbNode->presence); + cbNode->presence = NULL; result = OC_STACK_NO_MEMORY; goto exit; } @@ -3386,6 +3387,7 @@ OCStackResult OCProcessPresence() { FindAndDeleteClientCB(cbNode); } + continue; } if (now < cbNode->presence->timeOut[cbNode->presence->TTLlevel])