summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaewook Jung <jw0213.jung@samsung.com>2017-05-23 14:26:46 +0900
committerUze Choi <uzchoi@samsung.com>2017-05-23 08:24:06 +0000
commit2eca3ad480b0628eb7ba44e070d222fed49bf469 (patch)
tree07c9b11ec08e32490520772460b14b1fa0ef51fd
parent7ab51a25dbd4ccf83623659a9805fd63263d9a6d (diff)
downloadiotivity-2eca3ad480b0628eb7ba44e070d222fed49bf469.tar.gz
iotivity-2eca3ad480b0628eb7ba44e070d222fed49bf469.tar.bz2
iotivity-2eca3ad480b0628eb7ba44e070d222fed49bf469.zip
[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: Jaewook Jung <jw0213.jung@samsung.com> Reviewed-on: https://gerrit.iotivity.org/gerrit/20297 Reviewed-by: Uze Choi <uzchoi@samsung.com> Tested-by: Uze Choi <uzchoi@samsung.com>
-rw-r--r--resource/csdk/security/src/secureresourcemanager.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/resource/csdk/security/src/secureresourcemanager.c b/resource/csdk/security/src/secureresourcemanager.c
index b95b122b2..bd447b615 100644
--- a/resource/csdk/security/src/secureresourcemanager.c
+++ b/resource/csdk/security/src/secureresourcemanager.c
@@ -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);
}
}