From: Erich Keane Date: Fri, 16 Jan 2015 22:46:53 +0000 (-0800) Subject: Fixed issue with HeaderOptions not correctly being sent X-Git-Tag: 1.2.0+RC1~1855^2~258 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7a1896e8dcbdd48442f4ca9b2f69ee52dfefa384;p=platform%2Fupstream%2Fiotivity.git Fixed issue with HeaderOptions not correctly being sent If HeaderOptions count was greater than 1, the sender side did not correctly allocate and copy the memory for it, resulting in the second headeroption being an invalid read/copy, thus resulting in garbage data in the second HeaderOption. This fix ensures that ALL header option data is correctly copied. Validation shows that the rst of the stack is working properly, so the correct data will be transferred. Change-Id: I08d9ccf8943bf7e85f6d24055b5f11881ba2bd24 Signed-off-by: Erich Keane Reviewed-on: https://gerrit.iotivity.org/gerrit/153 Tested-by: jenkins-iotivity Reviewed-by: Sudarshan Prasad Reviewed-by: Sakthivel Samidurai Reviewed-by: Sashi Penta Reviewed-by: Ashok Babu Channa Tested-by: Ashok Babu Channa --- diff --git a/resource/csdk/connectivity/src/caremotehandler.c b/resource/csdk/connectivity/src/caremotehandler.c index 6807623..1bf864c 100644 --- a/resource/csdk/connectivity/src/caremotehandler.c +++ b/resource/csdk/connectivity/src/caremotehandler.c @@ -313,10 +313,11 @@ CARequestInfo_t *CACloneRequestInfo(const CARequestInfo_t *rep) clone->info.token = temp; } - if (rep->info.options != NULL) + if (rep->info.options != NULL && rep->info.numOptions > 0) { // save the options - clone->info.options = (CAHeaderOption_t *) OICMalloc(sizeof(CAHeaderOption_t)); + clone->info.options = + (CAHeaderOption_t *) OICMalloc(sizeof(CAHeaderOption_t) * clone->info.numOptions); if (clone->info.options == NULL) { OIC_LOG(DEBUG, TAG, "CACloneRequestInfo Out of memory"); @@ -324,8 +325,9 @@ CARequestInfo_t *CACloneRequestInfo(const CARequestInfo_t *rep) OICFree(clone); return NULL; } - memset(clone->info.options, 0, sizeof(CAHeaderOption_t)); - memcpy(clone->info.options, rep->info.options, sizeof(CAHeaderOption_t)); + memcpy(clone->info.options, + rep->info.options, + sizeof(CAHeaderOption_t) * clone->info.numOptions); } if (rep->info.payload != NULL)