From 557f1a83fc2108899640a599d9bb5e22bc5bc91b Mon Sep 17 00:00:00 2001 From: samanway Date: Tue, 23 Jul 2019 17:35:15 +0530 Subject: [PATCH] Adding fix for Sonarqube major issues for IoTivity 1.2-rel - Fixed Invalid number of character ')'s in caleadapter.c - Fixed Possible null pointer dereference in ccmessagehandler.c - Fixed double memory free condition JniNotificationConsumer.cpp - Fixed double memory free condition JniNotificationProvider.cpp https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/548/commits/222bbb7e84830c5a2ecc17332df1c60f2bcf3a71 (cherry-picked from 222bbb7e84830c5a2ecc17332df1c60f2bcf3a71) Change-Id: I724ee387dfc932c0614b7e19bb289b85d0254106 Signed-off by: samanway Signed-off-by: Sudipto --- resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c | 2 +- resource/csdk/connectivity/src/camessagehandler.c | 5 +++++ .../src/main/jni/consumer/JniNotificationConsumer.cpp | 1 + .../src/main/jni/provider/JniNotificationProvider.cpp | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c b/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c index d9ac819..10fdffd 100644 --- a/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c +++ b/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c @@ -2006,7 +2006,7 @@ static void CALEDataReceiverHandlerSingleThread(const uint8_t *data, static CAResult_t CALEServerSendDataSingleThread(const uint8_t *data, uint32_t dataLen) { - OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "%s", __func__);); + OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "%s", __func__); VERIFY_NON_NULL(data, CALEADAPTER_TAG, "Param data is NULL"); diff --git a/resource/csdk/connectivity/src/camessagehandler.c b/resource/csdk/connectivity/src/camessagehandler.c index 41b8884..c4b25dd 100644 --- a/resource/csdk/connectivity/src/camessagehandler.c +++ b/resource/csdk/connectivity/src/camessagehandler.c @@ -1642,6 +1642,11 @@ static void CALogPDUInfo(const CAData_t *data, const coap_pdu_t *pdu) char log_buffer[1024] = ""; sprintf(log_buffer, "CA_LOG [%5d] | %-13s | %-12s | msg size : %4d | %s", pdu->transport_hdr->udp.id , type, method, pdu->length, info->resourceUri); + if(NULL != info) + { + sprintf(log_buffer, "CA_LOG [%5d] | %-13s | %-12s | msg size : %4d | %s", pdu->transport_hdr->udp.id , type, method, pdu->length, info->resourceUri); + } + puts(log_buffer); } diff --git a/service/notification/android/notification-service/src/main/jni/consumer/JniNotificationConsumer.cpp b/service/notification/android/notification-service/src/main/jni/consumer/JniNotificationConsumer.cpp index 7abe708..4c592e0 100755 --- a/service/notification/android/notification-service/src/main/jni/consumer/JniNotificationConsumer.cpp +++ b/service/notification/android/notification-service/src/main/jni/consumer/JniNotificationConsumer.cpp @@ -602,6 +602,7 @@ jobject getJavaMessage(JNIEnv *env, OIC::Service::NSMessage message) { NS_LOGE ("Failed to create OcRepresentation"); delete ocRepresentation; + return NULL; } else { diff --git a/service/notification/android/notification-service/src/main/jni/provider/JniNotificationProvider.cpp b/service/notification/android/notification-service/src/main/jni/provider/JniNotificationProvider.cpp index 2c4ee96..4658fb7 100755 --- a/service/notification/android/notification-service/src/main/jni/provider/JniNotificationProvider.cpp +++ b/service/notification/android/notification-service/src/main/jni/provider/JniNotificationProvider.cpp @@ -548,6 +548,7 @@ jobject getJavaMessage(JNIEnv *env, OIC::Service::NSMessage message) { NS_LOGE ("Failed to create OcRepresentation"); delete ocRepresentation; + return NULL; } else { -- 2.7.4