From 2dcb10f8fc9ca52cf1956c928664d2ad6f2a98ab Mon Sep 17 00:00:00 2001 From: Randeep Singh Date: Tue, 29 Nov 2016 16:44:30 +0530 Subject: [PATCH] resolved svace issues Change-Id: If2b022d06a46c46cba1b3535c49ddcdbc794bf3c Signed-off-by: Randeep Singh Reviewed-on: https://gerrit.iotivity.org/gerrit/14907 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi Reviewed-by: Jongmin Choi Reviewed-by: Jongsung Lee (cherry picked from commit 73c1e373ddba4e748fc1466e352f812038a17b3e) Reviewed-on: https://gerrit.iotivity.org/gerrit/14943 --- .../csdk/security/provisioning/sample/sampleserver_justworks.cpp | 2 +- .../csdk/security/provisioning/sample/sampleserver_randompin.cpp | 2 +- .../security/provisioning/src/multipleownershiptransfermanager.c | 5 ++++- resource/csdk/security/provisioning/src/ownershiptransfermanager.c | 5 ----- resource/csdk/security/provisioning/unittest/sampleserver1.cpp | 2 +- resource/csdk/security/provisioning/unittest/sampleserver2.cpp | 2 +- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/resource/csdk/security/provisioning/sample/sampleserver_justworks.cpp b/resource/csdk/security/provisioning/sample/sampleserver_justworks.cpp index fcf752d..94d79d0 100644 --- a/resource/csdk/security/provisioning/sample/sampleserver_justworks.cpp +++ b/resource/csdk/security/provisioning/sample/sampleserver_justworks.cpp @@ -278,7 +278,7 @@ OCEntityHandlerResult ProcessPostRequest (OCEntityHandlerRequest *ehRequest, gLedInstance[gCurrLedInstance].state = 0; gLedInstance[gCurrLedInstance].power = 0; gCurrLedInstance++; - strncpy ((char *)response->resourceUri, newLedUri, MAX_URI_LENGTH); + strncpy ((char *)response->resourceUri, newLedUri, sizeof(response->resourceUri)); ehResult = OC_EH_RESOURCE_CREATED; } } diff --git a/resource/csdk/security/provisioning/sample/sampleserver_randompin.cpp b/resource/csdk/security/provisioning/sample/sampleserver_randompin.cpp index dc10ede..81b07c4 100644 --- a/resource/csdk/security/provisioning/sample/sampleserver_randompin.cpp +++ b/resource/csdk/security/provisioning/sample/sampleserver_randompin.cpp @@ -314,7 +314,7 @@ OCEntityHandlerResult ProcessPostRequest (OCEntityHandlerRequest *ehRequest, gLedInstance[gCurrLedInstance].state = 0; gLedInstance[gCurrLedInstance].power = 0; gCurrLedInstance++; - strncpy ((char *)response->resourceUri, newLedUri, MAX_URI_LENGTH); + strncpy ((char *)response->resourceUri, newLedUri, sizeof(response->resourceUri)); ehResult = OC_EH_RESOURCE_CREATED; } } diff --git a/resource/csdk/security/provisioning/src/multipleownershiptransfermanager.c b/resource/csdk/security/provisioning/src/multipleownershiptransfermanager.c index 1206fa1..6a84d27 100644 --- a/resource/csdk/security/provisioning/src/multipleownershiptransfermanager.c +++ b/resource/csdk/security/provisioning/src/multipleownershiptransfermanager.c @@ -541,7 +541,10 @@ static void SetMOTResult(OTMContext_t* motCtx, const OCStackResult res) //If there is a request being performed, cancel it to prevent retransmission. if(motCtx->ocDoHandle) { - OCCancel(motCtx->ocDoHandle, OC_HIGH_QOS, NULL, 0); + if (OC_STACK_OK != OCCancel(motCtx->ocDoHandle, OC_HIGH_QOS, NULL, 0)) + { + OIC_LOG(ERROR, TAG, "Failed to remove registered callback"); + } motCtx->ocDoHandle = NULL; } diff --git a/resource/csdk/security/provisioning/src/ownershiptransfermanager.c b/resource/csdk/security/provisioning/src/ownershiptransfermanager.c index 5a06faf..9e7f9ce 100644 --- a/resource/csdk/security/provisioning/src/ownershiptransfermanager.c +++ b/resource/csdk/security/provisioning/src/ownershiptransfermanager.c @@ -1898,11 +1898,6 @@ OCStackResult OTMDoOwnershipTransfer(void* ctx, OIC_LOG(DEBUG, TAG, "OUT OTMDoOwnershipTransfer"); return OC_STACK_OK; - -error: - OICFree(otmCtx->ctxResultArray); - OICFree(otmCtx); - return res; } OCStackResult OTMSetOxmAllowStatus(const OicSecOxm_t oxm, const bool allowStatus) diff --git a/resource/csdk/security/provisioning/unittest/sampleserver1.cpp b/resource/csdk/security/provisioning/unittest/sampleserver1.cpp index 7575811..5b1fc82 100644 --- a/resource/csdk/security/provisioning/unittest/sampleserver1.cpp +++ b/resource/csdk/security/provisioning/unittest/sampleserver1.cpp @@ -345,7 +345,7 @@ OCEntityHandlerResult ProcessPostRequest (OCEntityHandlerRequest *ehRequest, gLedInstance[gCurrLedInstance].state = 0; gLedInstance[gCurrLedInstance].power = 0; gCurrLedInstance++; - strncpy ((char *)response->resourceUri, newLedUri, MAX_URI_LENGTH); + strncpy ((char *)response->resourceUri, newLedUri, sizeof(response->resourceUri)); ehResult = OC_EH_RESOURCE_CREATED; } } diff --git a/resource/csdk/security/provisioning/unittest/sampleserver2.cpp b/resource/csdk/security/provisioning/unittest/sampleserver2.cpp index 73440e6..bb70573 100644 --- a/resource/csdk/security/provisioning/unittest/sampleserver2.cpp +++ b/resource/csdk/security/provisioning/unittest/sampleserver2.cpp @@ -345,7 +345,7 @@ OCEntityHandlerResult ProcessPostRequest (OCEntityHandlerRequest *ehRequest, gLedInstance[gCurrLedInstance].state = 0; gLedInstance[gCurrLedInstance].power = 0; gCurrLedInstance++; - strncpy ((char *)response->resourceUri, newLedUri, MAX_URI_LENGTH); + strncpy ((char *)response->resourceUri, newLedUri, sizeof(response->resourceUri)); ehResult = OC_EH_RESOURCE_CREATED; } } -- 2.7.4