Commit 2eca3ad4 authored by Jaewook Jung's avatar Jaewook Jung Committed by Uze Choi

[IOT-2342] Fix a crash issue on secureresourcemanager.c

Add null checking for a resource object which could be NULL if server
receives a request message including resource uri which server doesn't
have.

Change-Id: Idf29a43aeca5a919c0b22d3f0cd9ce507c8935ab
Signed-off-by: default avatarJaewook Jung <jw0213.jung@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/20297Reviewed-by: default avatarUze Choi <uzchoi@samsung.com>
Tested-by: default avatarUze Choi <uzchoi@samsung.com>
parent 7ab51a25
......@@ -167,32 +167,38 @@ static void SetResourceUriAndType(SRMRequestContext_t *context)
static void SetDiscoverable(SRMRequestContext_t *context)
{
OCResource *resource;
if (NULL == context)
{
OIC_LOG_V(ERROR, TAG, "%s: Null context.", __func__);
context->discoverable = DISCOVERABLE_NOT_KNOWN;
return;
}
else if (NULL == context->resourceUri)
if (NULL == context->resourceUri)
{
OIC_LOG_V(ERROR, TAG, "%s: Null resourceUri.", __func__);
context->discoverable = DISCOVERABLE_NOT_KNOWN;
return;
}
OCResource *resource = FindResourceByUri(context->resourceUri);
if (NULL == resource)
{
OIC_LOG_V(ERROR, TAG, "%s: Unkown resourceUri(%s).", __func__, context->resourceUri);
context->discoverable = DISCOVERABLE_NOT_KNOWN;
return;
}
if (OC_DISCOVERABLE == (resource->resourceProperties & OC_DISCOVERABLE))
{
context->discoverable = DISCOVERABLE_TRUE;
OIC_LOG_V(DEBUG, TAG, "%s: resource %s is OC_DISCOVERABLE.",
__func__, context->resourceUri);
}
else
{
resource = FindResourceByUri(context->resourceUri);
if (OC_DISCOVERABLE == (resource->resourceProperties & OC_DISCOVERABLE))
{
context->discoverable = DISCOVERABLE_TRUE;
OIC_LOG_V(DEBUG, TAG, "%s: resource %s is OC_DISCOVERABLE.",
__func__, context->resourceUri);
}
else
{
context->discoverable = DISCOVERABLE_FALSE;
OIC_LOG_V(DEBUG, TAG, "%s: resource %s is NOT OC_DISCOVERABLE.",
__func__, context->resourceUri);
}
context->discoverable = DISCOVERABLE_FALSE;
OIC_LOG_V(DEBUG, TAG, "%s: resource %s is NOT OC_DISCOVERABLE.",
__func__, context->resourceUri);
}
}
......
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