From 241e76c83217d4b6e21c80fc49ccfe248fc5afeb Mon Sep 17 00:00:00 2001 From: Satya Prakash Gupta Date: Thu, 18 Jun 2015 16:43:33 +0530 Subject: [PATCH] Fix NULL pointer deferencing in sample program. Fix NULL pointer deferencing in send_response. Change-Id: Ie38dd5d4d0c95fe4a8ccc26a23612584816ef442 Signed-off-by: Satya Prakash Gupta Reviewed-on: https://gerrit.iotivity.org/gerrit/1342 Tested-by: jenkins-iotivity Reviewed-by: Erich Keane --- resource/csdk/connectivity/samples/linux/sample_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resource/csdk/connectivity/samples/linux/sample_main.c b/resource/csdk/connectivity/samples/linux/sample_main.c index 1a984ec..a8e0df1 100644 --- a/resource/csdk/connectivity/samples/linux/sample_main.c +++ b/resource/csdk/connectivity/samples/linux/sample_main.c @@ -1141,7 +1141,7 @@ void send_response(const CAEndpoint_t *endpoint, const CAInfo_t *info) CAInfo_t responseData = { 0 }; responseData.type = messageType; responseData.messageId = (info != NULL) ? info->messageId : 0; - responseData.resourceUri = info->resourceUri; + responseData.resourceUri = (info != NULL) ? info->resourceUri : 0; if(CA_MSG_RESET != messageType) { @@ -1159,7 +1159,7 @@ void send_response(const CAEndpoint_t *endpoint, const CAInfo_t *info) printf("Memory allocation fail\n"); return; } - snprintf(responseData.payload, length, SECURE_INFO_DATA, info->resourceUri, + snprintf(responseData.payload, length, SECURE_INFO_DATA, responseData.resourceUri, g_local_secure_port); } else @@ -1173,7 +1173,7 @@ void send_response(const CAEndpoint_t *endpoint, const CAInfo_t *info) printf("Memory allocation fail\n"); return; } - snprintf(responseData.payload, length, NORMAL_INFO_DATA, info->resourceUri); + snprintf(responseData.payload, length, NORMAL_INFO_DATA, responseData.resourceUri); } } -- 2.7.4