Fix for issue of CA don't check the invalid CAResponseInfo_t.result.
authorhyuna0213.jo <hyuna0213.jo@samsung.com>
Fri, 29 May 2015 01:06:13 +0000 (10:06 +0900)
committerErich Keane <erich.keane@intel.com>
Fri, 29 May 2015 16:11:04 +0000 (16:11 +0000)
currently, CA don't check the value of CAResponseInfo_t.result.
so I add the logic which CA check whether CAResponseInfo_t.result
is valid value.
This issue is related to IOT-385, IOT-386.

Change-Id: I8fdb7bc021c2b294b068d202a5bd6d5131d1904d
Signed-off-by: hyuna0213.jo <hyuna0213.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1133
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: John Light <john.j.light@intel.com>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/connectivity/src/caremotehandler.c

index 9bf509a..7e3f114 100644 (file)
@@ -392,6 +392,25 @@ CAResponseInfo_t *CACloneResponseInfo(const CAResponseInfo_t *rep)
         return NULL;
     }
 
+    // check the result value of response info.
+    switch (rep->result)
+    {
+        case CA_EMPTY:
+        case CA_SUCCESS:
+        case CA_CREATED:
+        case CA_DELETED:
+        case CA_BAD_REQ:
+        case CA_BAD_OPT:
+        case CA_NOT_FOUND:
+        case CA_INTERNAL_SERVER_ERROR:
+        case CA_RETRANSMIT_TIMEOUT:
+            break;
+
+        default:
+            OIC_LOG(ERROR, TAG, "Response status code is invalid number");
+            return NULL;
+    }
+
     // allocate the response info structure.
     CAResponseInfo_t *clone = (CAResponseInfo_t *) OICCalloc(1, sizeof(CAResponseInfo_t));
     if (NULL == clone)