IOT-3079 Fix change port number issue 41/25441/4
authorJeonghwan Kim <addy.kim@lge.com>
Thu, 24 May 2018 01:09:49 +0000 (10:09 +0900)
committerJEONGHWAN KIM <addy.kim@lge.com>
Fri, 25 May 2018 02:03:43 +0000 (02:03 +0000)
When using provisioning tool, this code change to target dev's port number.
reproduction case is below in provisioning tol.

1. Discovery All devices or unowned devices.
2. do Ownership transfers.
3. hard reset device.

4. Discovery All devices
5. Do Ownership transfer.

it happens to error in provisioning tool because of changing to target's port number

Conflicts:
resource/csdk/security/provisioning/src/ocprovisioningmanager.c

Change-Id: Ie5bcc1be58bc11609dd3bcc0b674d64202ed4573
Signed-off-by: Jeonghwan Kim <addy.kim@lge.com>
resource/csdk/security/provisioning/src/ocprovisioningmanager.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 3e34c52..69d5067
@@ -713,18 +713,23 @@ static OCStackResult RemoveDeviceInfoFromLocal(const OCProvisionDev_t* pTargetDe
     }
 
     // TODO: We need to add new mechanism to clean up the stale state of the device.
-
     // Close the DTLS session of the removed device.
-    CAEndpoint_t endpoint = {.adapter = CA_DEFAULT_ADAPTER};
-    CopyDevAddrToEndpoint(&pTargetDev->endpoint, &endpoint);
-    endpoint.port = pTargetDev->securePort;
-    CAResult_t caResult = CAcloseSslSession(&endpoint);
+    CAEndpoint_t *endpoint = (CAEndpoint_t *) OICMalloc(sizeof(pTargetDev->endpoint));
+    if (!endpoint)
+    {
+        OIC_LOG(ERROR, TAG, "memory alloc has failed");
+        return OC_STACK_NO_MEMORY;
+    }
+    memcpy(endpoint, &pTargetDev->endpoint, sizeof(CAEndpoint_t) );
+    endpoint->port = pTargetDev->securePort;
+    CAResult_t caResult = CAcloseSslSession(endpoint);
     if(CA_STATUS_OK != caResult)
     {
         OIC_LOG_V(WARNING, TAG, "OCRemoveDevice : Failed to close DTLS session : %d", caResult);
     }
-
+    OICFree(endpoint);
     OIC_LOG(DEBUG, TAG, "OUT RemoveDeviceInfoFromLocal");
+
 error:
     return res;
 }