Fix NULL pointer deferencing in sample program.
authorSatya Prakash Gupta <sp.gupta@samsung.com>
Thu, 18 Jun 2015 11:13:33 +0000 (16:43 +0530)
committerErich Keane <erich.keane@intel.com>
Mon, 22 Jun 2015 20:36:03 +0000 (20:36 +0000)
Fix NULL pointer deferencing in send_response.

Change-Id: Ie38dd5d4d0c95fe4a8ccc26a23612584816ef442
Signed-off-by: Satya Prakash Gupta <sp.gupta@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1342
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/connectivity/samples/linux/sample_main.c

index 1a984ec..a8e0df1 100644 (file)
@@ -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);
         }
     }