check the method type of request info.
authorhyuna0213.jo <hyuna0213.jo@samsung.com>
Mon, 14 Dec 2015 11:01:14 +0000 (20:01 +0900)
committerJon A. Cruz <jonc@osg.samsung.com>
Mon, 14 Dec 2015 20:58:01 +0000 (20:58 +0000)
if method type of request info is invalid,
CA has to return error code to RI Layer.

Change-Id: Ic34da1c13e63172885a44a114a86f52cbbb34f6f
Signed-off-by: hyuna0213.jo <hyuna0213.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/4565
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: MyeongGi Jeong <myeong.jeong@samsung.com>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
resource/csdk/connectivity/common/src/caremotehandler.c

index a39b7d4..1315dae 100644 (file)
@@ -55,6 +55,20 @@ CARequestInfo_t *CACloneRequestInfo(const CARequestInfo_t *rep)
         return NULL;
     }
 
+    // check the method type of request info.
+    // Keep this check in sync with CAMethod_t
+    switch (rep->method)
+    {
+        case CA_GET:
+        case CA_POST:
+        case CA_PUT:
+        case CA_DELETE:
+            break;
+        default:
+            OIC_LOG_V(ERROR, TAG, "Method %u is invalid", rep->method);
+            return NULL;
+    }
+
     // allocate the request info structure.
     CARequestInfo_t *clone = (CARequestInfo_t *) OICMalloc(sizeof(CARequestInfo_t));
     if (!clone)