Commit c22b1d43 authored by Ziran Sun's avatar Ziran Sun

Add Failure check for OCGetResourceIns() in OCRDDeleteWithDeviceId().

Bug: https://jira.iotivity.org/browse/IOT-1809
Change-Id: I1aac3d7fae0dfc5fbee4d9715b328d18bd492b14
Signed-off-by: default avatarZiran Sun <ziran.sun@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/20317Tested-by: default avatarjenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: default avatarTodd Malsbary <todd.malsbary@intel.com>
Reviewed-by: default avatarDan Mihai <Daniel.Mihai@microsoft.com>
parent a532ef72
...@@ -450,15 +450,17 @@ OCStackResult OCRDDeleteWithDeviceId(OCDoHandle *handle, const char *host, ...@@ -450,15 +450,17 @@ OCStackResult OCRDDeleteWithDeviceId(OCDoHandle *handle, const char *host,
{ {
OCResource *handle = (OCResource *) resourceHandles[j]; OCResource *handle = (OCResource *) resourceHandles[j];
int64_t ins = 0; int64_t ins = 0;
OCGetResourceIns(handle, &ins); if (OC_STACK_OK == OCGetResourceIns(handle, &ins))
int lenBufferRequired = snprintf((queryParam + queryLength),
(MAX_URI_LENGTH - queryLength), "&ins=%" PRId64, ins);
if (lenBufferRequired >= (MAX_URI_LENGTH - queryLength) || lenBufferRequired < 0)
{ {
return OC_STACK_INVALID_URI; int lenBufferRequired = snprintf((queryParam + queryLength),
(MAX_URI_LENGTH - queryLength), "&ins=%" PRId64, ins);
if (lenBufferRequired >= (MAX_URI_LENGTH - queryLength) || lenBufferRequired < 0)
{
return OC_STACK_INVALID_URI;
}
queryLength += lenBufferRequired;
OIC_LOG_V(DEBUG, TAG, "queryParam [%s]", queryParam);
} }
queryLength += lenBufferRequired;
OIC_LOG_V(DEBUG, TAG, "queryParam [%s]", queryParam);
} }
if (targetUriBufferRequired + queryLength + 1 > MAX_URI_LENGTH) if (targetUriBufferRequired + queryLength + 1 > MAX_URI_LENGTH)
......
...@@ -5997,11 +5997,17 @@ OCStackResult OCUpdateResourceInsWithResponse(const char *requestUri, ...@@ -5997,11 +5997,17 @@ OCStackResult OCUpdateResourceInsWithResponse(const char *requestUri,
if (resHandle) if (resHandle)
{ {
int64_t resIns = 0; int64_t resIns = 0;
OCGetResourceIns(resHandle, &resIns); if (OC_STACK_OK == OCGetResourceIns(resHandle, &resIns))
if (queryIns && queryIns == resIns)
{ {
OCBindResourceInsToResource(resHandle, 0); if (queryIns && queryIns == resIns)
break; {
OCBindResourceInsToResource(resHandle, 0);
break;
}
}
else
{
OIC_LOG(ERROR, TAG, "Get resource instance failed!");
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment