From aa38f4fea6ebade64544e306c815347002422cc0 Mon Sep 17 00:00:00 2001 From: Ziran Sun Date: Wed, 31 May 2017 15:08:05 +0100 Subject: [PATCH] Fix ocserver sample code that causes memory corrupt. Bug: https://jira.iotivity.org/browse/IOT-2381 Change-Id: I3aca7c79d97a2e4295568dbbb24de384b6993f50 Signed-off-by: Ziran Sun Reviewed-on: https://gerrit.iotivity.org/gerrit/20497 Tested-by: jenkins-iotivity --- .../csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp b/resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp index 1888173..40aa69b 100644 --- a/resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp +++ b/resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp @@ -652,13 +652,14 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, { OIC_LOG_V(INFO, TAG, "accept version option exists"); OIC_LOG_BUFFER(INFO, TAG, vOptionData, MAX_HEADER_OPTION_DATA_LENGTH); - } - uint16_t acceptVersion = vOptionData[0]*256 + vOptionData[1]; - if (OC_SPEC_VERSION_VALUE == acceptVersion) - { - OIC_LOG_V(INFO, TAG, "accept version equals to default OC_SPEC_VERSION_VALUE."); + uint16_t acceptVersion = vOptionData[0]*256 + vOptionData[1]; + if (OC_SPEC_VERSION_VALUE == acceptVersion) + { + OIC_LOG_V(INFO, TAG, "accept version equals to default OC_SPEC_VERSION_VALUE."); + } } + actualDataSize = 0; OCHeaderOption* sendOptions = response.sendVendorSpecificHeaderOptions; size_t numOptions = response.numSendVendorSpecificHeaderOptions; // Check if the option header has already existed before adding it in. @@ -702,7 +703,6 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, option3, optionDataSize3); } - response.numSendVendorSpecificHeaderOptions = 2; } // Send the response -- 2.7.4