From 80b4416e37406c9a87a7ef6e00a1428d88e2e348 Mon Sep 17 00:00:00 2001 From: Yuliya Kamatkova Date: Fri, 12 Dec 2014 12:59:53 -0500 Subject: [PATCH] Fixed OCCreateResource return type when empty URI is passed Defect IOT-109: OCCreateResource in the C SDK previously allowed empty URI. The defect was fixed: OCCreateResource returns error status OC_STACK_INVALID_URI if empty URI string is passed Note: There are other places in code where only NULL check is performed for URIs however empty string check is not performed. Change-Id: Ia23fd2be20677614f267c73160ebefc56a5e6d71 Signed-off-by: Yuliya Kamatkova --- resource/csdk/stack/src/ocstack.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/resource/csdk/stack/src/ocstack.c b/resource/csdk/stack/src/ocstack.c index eb0aef8..6d0f3c2 100644 --- a/resource/csdk/stack/src/ocstack.c +++ b/resource/csdk/stack/src/ocstack.c @@ -935,8 +935,13 @@ OCStackResult OCCreateResource(OCResourceHandle *handle, return result; } // Validate parameters + if(!uri || (strlen(uri) == 0)) + { + OC_LOG(ERROR, TAG, PCF("URI is invalid")); + return OC_STACK_INVALID_URI; + } // Is it presented during resource discovery? - if (!handle || !resourceTypeName || !uri) { + if (!handle || !resourceTypeName) { OC_LOG(ERROR, TAG, PCF("Input parameter is NULL")); return OC_STACK_INVALID_PARAM; } -- 2.7.4