From 176c9ded8f1aeb60bb2e6d9966d7b4253c1cd033 Mon Sep 17 00:00:00 2001 From: Sourav Bhuwalka Date: Fri, 10 Jan 2020 12:56:17 +0530 Subject: [PATCH] Iotivity crash on 502 Bad Gateway error Initialising dimensions with 0 which was not done earlier In case OCRepPayloadGetPropObjectArray function fails links become NULL but since dimensions is not initailised with 0 it will have some garbage value and will enter in loop and crash will occur https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/649/commits/3a10bc1df11c5c2bbf7465e3aa06a76adb4734c6 (cherry-picked from 3a10bc1df11c5c2bbf7465e3aa06a76adb4734c6) Change-Id: I9f156c9f3459ad756d3fde2759aa518d48380d54 Signed-off-by: Sudipto --- resource/csdk/resource-directory/src/RDClient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resource/csdk/resource-directory/src/RDClient.cpp b/resource/csdk/resource-directory/src/RDClient.cpp index cc1dfc0..c4ac211 100644 --- a/resource/csdk/resource-directory/src/RDClient.cpp +++ b/resource/csdk/resource-directory/src/RDClient.cpp @@ -82,7 +82,7 @@ OCStackApplicationResult publishResourceToRDCallback(void* ctx, OCDoHandle /*han OCRepPayload *rdPayload = (OCRepPayload *) clientResponse->payload; OCRepPayload **links = NULL; - size_t dimensions[MAX_REP_ARRAY_DEPTH]; + size_t dimensions[MAX_REP_ARRAY_DEPTH] = { 0 }; OCRepPayloadGetPropObjectArray(rdPayload, OC_RSRVD_LINKS, &links, dimensions); for(size_t i = 0; i < dimensions[0]; i++) { -- 2.7.4