diff options
author | senthil.gs@samsung.com <senthil.gs@samsung.com> | 2019-11-27 11:15:02 +0530 |
---|---|---|
committer | DoHyun Pyun <dh79.pyun@samsung.com> | 2019-11-28 16:28:37 +0900 |
commit | 70fe9239d3c115e636410da4629f5105f72d2f41 (patch) | |
tree | a493744e184ab847a1652f2fc9474fee2d93938c | |
parent | 49515e2825ea7997159ab81308ff3dae771d72b6 (diff) | |
download | iotivity-70fe9239d3c115e636410da4629f5105f72d2f41.tar.gz iotivity-70fe9239d3c115e636410da4629f5105f72d2f41.tar.bz2 iotivity-70fe9239d3c115e636410da4629f5105f72d2f41.zip |
Fix for crash at FindResourceByUri(). (#629)
NULL check was not there before accessing "pointer->uri" due to which segmentation fault has occurred.
So NULL check is done at two different places.
https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/629
(cherry-picked from 727d5f58b67d83d3c82452b0afb7781bba59ec81)
Change-Id: I77878da7f89858235feafbc7b25a4e1fef39a52a
Signed-off-by: Senthil Kumar G S <senthil.gs@samsung.com>
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
-rw-r--r-- | resource/csdk/stack/src/ocresource.c | 3 | ||||
-rw-r--r-- | resource/csdk/stack/src/ocstack.c | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/resource/csdk/stack/src/ocresource.c b/resource/csdk/stack/src/ocresource.c index bf82aa28b..287244b98 100644 --- a/resource/csdk/stack/src/ocresource.c +++ b/resource/csdk/stack/src/ocresource.c @@ -555,6 +555,7 @@ OCStackResult BuildVirtualResourceResponse(const OCResource *resourcePtr, return OC_STACK_OK; } +// TODO: headResource needs to be accessed in a thread-safe manner OCResource *FindResourceByUri(const char* resourceUri) { if(!resourceUri) @@ -565,7 +566,7 @@ OCResource *FindResourceByUri(const char* resourceUri) OCResource * pointer = headResource; while (pointer) { - if (strcmp(resourceUri, pointer->uri) == 0) + if (pointer->uri && strcmp(resourceUri, pointer->uri) == 0) { return pointer; } diff --git a/resource/csdk/stack/src/ocstack.c b/resource/csdk/stack/src/ocstack.c index 57c14d9fa..4c799b1bc 100644 --- a/resource/csdk/stack/src/ocstack.c +++ b/resource/csdk/stack/src/ocstack.c @@ -5483,7 +5483,7 @@ OCResourceHandle OCGetResourceHandleAtUri(const char *uri) 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(DEBUG, TAG, "Found Resource %s", uri); return pointer; |