IoT-1516: Return error when WSARecvMsg() fails.
authorSoemin Tjong <stjong@microsoft.com>
Mon, 17 Apr 2017 23:11:29 +0000 (16:11 -0700)
committerDan Mihai <Daniel.Mihai@microsoft.com>
Tue, 25 Apr 2017 14:59:18 +0000 (14:59 +0000)
https://jira.iotivity.org/browse/IOT-1516?

Change-Id: I5c16b47c9a462ac0b8d9f47cfaea89a5f84baeeb
Signed-off-by: Soemin Tjong <stjong@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/19021
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
resource/csdk/connectivity/src/ip_adapter/caipserver.c

index 45c0643..82b5012 100644 (file)
@@ -619,12 +619,14 @@ static CAResult_t CAReceiveMessage(CASocketFd_t fd, CATransportFlags_t flags)
 
     uint32_t recvLen = 0;
     uint32_t ret = caglobals.ip.wsaRecvMsg(fd, &msg, (LPDWORD)&recvLen, 0,0);
-    OIC_LOG_V(DEBUG, TAG, "WSARecvMsg recvd %u bytes", recvLen);
     if (OC_SOCKET_ERROR == ret)
     {
         OIC_LOG_V(ERROR, TAG, "WSARecvMsg failed %i", WSAGetLastError());
+        return CA_STATUS_FAILED;
     }
 
+    OIC_LOG_V(DEBUG, TAG, "WSARecvMsg recvd %u bytes", recvLen);
+
     for (WSACMSGHDR *cmp = WSA_CMSG_FIRSTHDR(&msg); cmp != NULL;
          cmp = WSA_CMSG_NXTHDR(&msg, cmp))
     {
@@ -678,7 +680,7 @@ static CAResult_t CAReceiveMessage(CASocketFd_t fd, CATransportFlags_t flags)
     {
 #ifdef __WITH_DTLS__
 #ifdef TB_LOG
-        int decryptResult = 
+        int decryptResult =
 #endif
         CAdecryptSsl(&sep, (uint8_t *)recvBuffer, recvLen);
         OIC_LOG_V(DEBUG, TAG, "CAdecryptSsl returns [%d]", decryptResult);