Crash in OCCreateResource 20/211020/2
authorKush <kush.agrawal@samsung.com>
Tue, 16 Jul 2019 11:38:45 +0000 (17:08 +0530)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Thu, 1 Aug 2019 23:09:58 +0000 (08:09 +0900)
Added check for uri before strncmp

https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/544/commits/ba1c2fd49c1fd4f519c64943656a5329cf36b0bd
(cherry-picked from ba1c2fd49c1fd4f519c64943656a5329cf36b0bd)

Change-Id: Ieddc1809174a1360a1bb82a6aeec580cb34e4755
Signed-off-by: Kush <kush.agrawal@samsung.com>
Signed-off-by: Sudipto Bal <sudipto.bal@samsung.com>
resource/csdk/stack/src/ocstack.c

index caed6d9..086567e 100644 (file)
@@ -3682,7 +3682,7 @@ OCStackResult OCCreateResource(OCResourceHandle *handle,
         // repeated URLs, which are not allowed.  If a repeat is found, exit with an error
         while (pointer)
         {
-            if (strncmp(uri, pointer->uri, MAX_URI_LENGTH) == 0)
+            if (pointer->uri && strncmp(uri, pointer->uri, MAX_URI_LENGTH) == 0)
             {
                 OIC_LOG_V(ERROR, TAG, "Resource %s already exists", uri);
                 return OC_STACK_INVALID_PARAM;