Update change log and spec for wrt-plugins-tizen_0.4.65
[platform/framework/web/wrt-plugins-tizen.git] / src / DataControl / JSMappedDataControlConsumer.cpp
index db00b12..4bf3573 100644 (file)
@@ -27,6 +27,7 @@
 #include <TimeTracer.h>
 #include <ArgumentValidator.h> 
 #include <JSUtil.h>  
+#include "DataType.h"
 #include "DataControlFactory.h"
 #include "JSMappedDataControlConsumer.h"
 #include "DataControlAsyncCallbackManager.h"
@@ -225,6 +226,16 @@ JSValueRef JSMappedDataControlConsumer::addValue(
                unsigned int reqId = converter.toULong(reserveArguments[0]);
                std::string key = converter.toString(reserveArguments[1]);
                std::string value = converter.toString(reserveArguments[2]);
+
+               unsigned long dataSize = key.size() + value.size();
+               
+               if (dataSize > PROTOCOL_DATA_MAX) 
+               {
+                       return JSWebAPIErrorFactory::postException(context, exception, 
+                               JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Data is too big");
+               }
+
+               
                successCallback = converter.toFunctionOrNull(reserveArguments[3]);
                errorCallBack = converter.toFunctionOrNull(reserveArguments[4]);
 
@@ -344,6 +355,15 @@ JSValueRef JSMappedDataControlConsumer::updateValue(
                successCallback = converter.toFunctionOrNull(reserveArguments[4]);
                errorCallBack = converter.toFunctionOrNull(reserveArguments[5]);
 
+               unsigned long dataSize = key.size() + oldValue.size() + newValue.size();
+               
+               if (dataSize > PROTOCOL_DATA_MAX) 
+               {
+                       return JSWebAPIErrorFactory::postException(context, exception, 
+                               JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Data is too big");
+               }
+
+
                cbm->setOnSuccess(successCallback);
                cbm->setOnError(errorCallBack);
 
@@ -458,6 +478,16 @@ JSValueRef JSMappedDataControlConsumer::getValue(
 
                unsigned int reqId = converter.toULong(reserveArguments[0]);
                std::string key = converter.toString(reserveArguments[1]);
+
+               
+               unsigned long dataSize = key.size();
+               
+               if (dataSize > PROTOCOL_DATA_MAX) 
+               {
+                       return JSWebAPIErrorFactory::postException(context, exception, 
+                               JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Data is too big");
+               }
+
                successCallback = converter.toFunctionOrNull(reserveArguments[2]);
                errorCallBack = converter.toFunctionOrNull(reserveArguments[3]);
 
@@ -567,6 +597,15 @@ JSValueRef JSMappedDataControlConsumer::removeValue(
                unsigned int reqId = converter.toULong(reserveArguments[0]);
                std::string key = converter.toString(reserveArguments[1]);
                std::string value = converter.toString(reserveArguments[2]);
+
+               unsigned long dataSize = key.size() + value.size();
+               
+               if (dataSize > PROTOCOL_DATA_MAX) 
+               {
+                       return JSWebAPIErrorFactory::postException(context, exception, 
+                               JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Data is too big");
+               }
+
                successCallback = converter.toFunctionOrNull(reserveArguments[3]);
                errorCallBack = converter.toFunctionOrNull(reserveArguments[4]);