Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / android / android_api / base / jni / JniOcProvisioning.cpp
index eb3e990..52d5bc9 100644 (file)
@@ -85,7 +85,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcProvisioning_ownershipTransferCB
                 delete jniPinListener;
                 jniPinListener = new JniPinCheckListener(env, jListener);
                 CBData.loadSecretCB = InputPinCodeCallback;
-                CBData.createSecureSessionCB = CreateSecureSessionRandomPinCallbak;
+                CBData.createSecureSessionCB = CreateSecureSessionRandomPinCallback;
                 CBData.createSelectOxmPayloadCB = CreatePinBasedSelectOxmPayload;
                 CBData.createOwnerTransferPayloadCB = CreatePinBasedOwnerTransferPayload;
                 result = OCSecure::setOwnerTransferCallbackData((OicSecOxm_t)OxmType,
@@ -123,6 +123,11 @@ JNIEXPORT jobjectArray JNICALL Java_org_iotivity_base_OcProvisioning_discoverUno
 
     try
     {
+        if (timeout < 0)
+        {
+            ThrowOcException(OC_STACK_INVALID_PARAM, "Timeout value cannot be negative");
+            return nullptr;
+        }
         OCStackResult result = OCSecure::discoverUnownedDevices((unsigned short)timeout, list);
 
         if (OC_STACK_OK != result)
@@ -137,6 +142,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_iotivity_base_OcProvisioning_discoverUno
     {
         LOGE("%s", e.reason().c_str());
         ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+        return nullptr;
     }
 }
 
@@ -190,6 +196,11 @@ JNIEXPORT jobjectArray JNICALL Java_org_iotivity_base_OcProvisioning_discoverOwn
 
     try
     {
+        if (timeout < 0)
+        {
+            ThrowOcException(OC_STACK_INVALID_PARAM, "Timeout value cannot be negative");
+            return nullptr;
+        }
         OCStackResult result = OCSecure::discoverOwnedDevices((unsigned short)timeout, list);
         if (OC_STACK_OK != result)
         {
@@ -203,6 +214,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_iotivity_base_OcProvisioning_discoverOwn
     {
         LOGE("%s", e.reason().c_str());
         ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+        return nullptr;
     }
 }
 
@@ -219,6 +231,11 @@ JNIEXPORT jobjectArray JNICALL Java_org_iotivity_base_OcProvisioning_getDeviceSt
 
     try
     {
+        if (timeout < 0)
+        {
+            ThrowOcException(OC_STACK_INVALID_PARAM, "Timeout value cannot be negative");
+            return nullptr;
+        }
         OCStackResult result = OCSecure::getDevInfoFromNetwork((unsigned short)timeout,
                 ownedDevList, unownedDevList);
         if (OC_STACK_OK != result)
@@ -233,6 +250,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_iotivity_base_OcProvisioning_getDeviceSt
     {
         LOGE("%s", e.reason().c_str());
         ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+        return nullptr;
     }
 }