From 68f4ee0e44acc108612a21b7252839f3165ff669 Mon Sep 17 00:00:00 2001 From: Szymon Jastrzebski Date: Fri, 19 May 2017 12:58:22 +0200 Subject: [PATCH 01/16] [SystemInfo] Throwing NOT_SUPPORTED_ERR added [Verification] TCT SystemInfo passed 100% (TM1, TW1, TV) Signed-off-by: Szymon Jastrzebski Change-Id: I30f56f7539be3baa59ec68fe75c357b4b26080e5 --- src/systeminfo/systeminfo_api.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/systeminfo/systeminfo_api.js b/src/systeminfo/systeminfo_api.js index e09c977..2e5dc4f 100644 --- a/src/systeminfo/systeminfo_api.js +++ b/src/systeminfo/systeminfo_api.js @@ -46,6 +46,17 @@ var SystemInfoPropertyId = { ADS : 'ADS' }; +var SystemInfoPropertyIdToFeature = { + BATTERY : 'http://tizen.org/feature/battery', + CAMERA_FLASH : 'http://tizen.org/feature/camera.back.flash', + CELLULAR_NETWORK : 'http://tizen.org/feature/network.telephony', + DISPLAY : 'http://tizen.org/feature/screen', + ETHERNET_NETWORK : 'http://tizen.org/feature/network.ethernet', + SIM : 'http://tizen.org/feature/network.telephony', + NET_PROXY_NETWORK : 'http://tizen.org/feature/network.net_proxy', + WIFI_NETWORK : 'http://tizen.org/feature/network.wifi' +}; + //class SystemInfoDeviceCapability //////////////////////////////////////////////////// function SystemInfoDeviceCapability(data) { Object.defineProperties(this, { @@ -790,6 +801,15 @@ var _createPropertyArray = function (property, data) { return propertyArray; }; +var _checkPropertySupported = function(property){ + if (SystemInfoPropertyIdToFeature[property]) { + var supported = tizen.systeminfo.getCapability(SystemInfoPropertyIdToFeature[property]); + if (!supported) { + return false; + } + } + return true; +}; var getPropertyFunction = function(cppLabel, objectCreateFunction) { return function() { @@ -818,6 +838,16 @@ var getPropertyFunction = function(cppLabel, objectCreateFunction) { if (!propObject) { throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Property with id: ' + args.property + ' is not supported.'); } + + if (_checkPropertySupported(args.property) === false) { + setTimeout(function() { + native_.callIfPossible(args.errorCallback, + new WebAPIException(WebAPIException.NOT_SUPPORTED_ERR, + 'Property with id: ' + args.property + ' is not supported.')); + }, 0); + return; + } + var callback = function(result) { if (native_.isFailure(result)) { setTimeout(function() { @@ -1329,6 +1359,15 @@ var getListenerFunction = function (isArray) { } ]); + if (_checkPropertySupported(args.property) === false) { + setTimeout(function() { + native_.callIfPossible(args.errorCallback, + new WebAPIException(WebAPIException.NOT_SUPPORTED_ERR, + 'Property with id: ' + args.property + ' is not supported.')); + }, 0); + return; + } + var listener = { callback : args.successCallback, isArrayType : isArray, -- 2.7.4 From d246d13ce7ca0ee08e2731c3bd2c0e80dd7d09a5 Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Wed, 24 May 2017 12:10:23 +0200 Subject: [PATCH 02/16] [version] 1.84 Change-Id: I96ee3646219e313a394cdf73595eaea57876aca6 --- packaging/webapi-plugins.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index 48dd7ee..15e0d54 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -10,7 +10,7 @@ %define crosswalk_extensions_path %{_libdir}/%{crosswalk_extensions} Name: webapi-plugins -Version: 1.83 +Version: 1.84 Release: 0 License: Apache-2.0 and BSD-3-Clause and MIT Group: Development/Libraries -- 2.7.4 From bbf3bfdf07047b51b09038c612449aad562c4f58 Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Thu, 25 May 2017 14:10:25 +0200 Subject: [PATCH 03/16] fixed setters of DownloadRequest [Verification] Code checked with chrome console. TCT passrate 100%. Change-Id: I7c9976efaf900452ee3da63fb13a3de1f0fa4466 Signed-off-by: Piotr Kosko --- src/download/download_api.js | 28 ++++++++++++++++++++++------ src/download/download_instance.cc | 10 ++++++---- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/download/download_api.js b/src/download/download_api.js index 8e5d9c1..331fcdc 100755 --- a/src/download/download_api.js +++ b/src/download/download_api.js @@ -19,6 +19,7 @@ var privUtils_ = xwalk.utils; var validator_ = xwalk.utils.validator; var types_ = validator_.Types; var check_ = xwalk.utils.type; +var converter_ = xwalk.utils.converter; var callbackId = 0; @@ -126,7 +127,10 @@ var DownloadNetworkType = { tizen.DownloadRequest = function(url, destination, fileName, networkType, httpHeader) { validator_.isConstructorCall(this, tizen.DownloadRequest); - var url_ = url; + var url_ = converter_.toString(url); + var destination_ = destination === undefined ? '' : converter_.toString(destination); + var fileName_ = fileName === undefined ? '' : converter_.toString(fileName); + var networkType_; if (networkType === undefined || !(networkType in DownloadNetworkType)) { @@ -143,19 +147,31 @@ tizen.DownloadRequest = function(url, destination, fileName, networkType, httpHe }, set: function(value) { if (value !== null) { - url_ = value; + url_ = converter_.toString(value); } }, }, 'destination': { - writable: true, enumerable: true, - value: destination === undefined ? '' : destination, + get: function() { + return destination_; + }, + set: function(value) { + if (value !== null) { + destination_ = converter_.toString(value); + } + }, }, 'fileName': { - writable: true, enumerable: true, - value: fileName === undefined ? '' : fileName, + get: function() { + return fileName_; + }, + set: function(value) { + if (value !== null) { + fileName_ = converter_.toString(value); + } + }, }, 'networkType': { enumerable: true, diff --git a/src/download/download_instance.cc b/src/download/download_instance.cc index 0950619..490c183 100755 --- a/src/download/download_instance.cc +++ b/src/download/download_instance.cc @@ -483,6 +483,7 @@ void DownloadInstance::DownloadManagerStart LoggerD("Entered"); CHECK_PRIVILEGE_ACCESS(kPrivilegeDownload, &out); CHECK_EXIST(args, "callbackId", out) + CHECK_EXIST(args, "url", out) int ret; std::string networkType; @@ -490,23 +491,24 @@ void DownloadInstance::DownloadManagerStart DownloadInfoPtr diPtr(new DownloadInfo); diPtr->callbackId = static_cast(args.get("callbackId").get()); - diPtr->url = args.get("url").get(); + diPtr->url = args.get("url").is() ? args.get("url").get() : ""; if (!args.get("destination").is()) { - if (args.get("destination").get() != "") { + if (args.get("destination").is() && args.get("destination").get() != "") { diPtr->destination = args.get("destination").get(); diPtr->destination = common::FilesystemProvider::Create().GetRealPath(diPtr->destination); } } if (!args.get("fileName").is()) { - if (args.get("fileName").get() != "") { + if (args.get("fileName").is() && args.get("fileName").get() != "") { diPtr->file_name = args.get("fileName").get(); } } if (!args.get("networkType").is()) { - networkType = args.get("networkType").get(); + networkType = args.get("networkType").is() ? + args.get("networkType").get() : "ALL"; } bool network_support = false; -- 2.7.4 From 333c20a255888ac638011e9b59089d1aeac576c9 Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Wed, 31 May 2017 12:14:21 +0200 Subject: [PATCH 04/16] [version] 1.85 Change-Id: Ib8a70c3f450f4e96598b13f3018bb4bd37b74c1c --- packaging/webapi-plugins.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index 15e0d54..8b2ca0d 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -10,7 +10,7 @@ %define crosswalk_extensions_path %{_libdir}/%{crosswalk_extensions} Name: webapi-plugins -Version: 1.84 +Version: 1.85 Release: 0 License: Apache-2.0 and BSD-3-Clause and MIT Group: Development/Libraries -- 2.7.4 From 6c88b38eca114e0c7a3ec38a046e996cfe40cc2b Mon Sep 17 00:00:00 2001 From: Szymon Jastrzebski Date: Mon, 5 Jun 2017 09:16:04 +0200 Subject: [PATCH 05/16] [Convergence] Disabling Convergence module HQ requested to remove Convergence API from Tizen 3.0. Change-Id: Ide749fe9bd2f23c1d0c845042d7530fe3146cafc --- packaging/webapi-plugins.spec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index 8b2ca0d..bf4febe 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -210,7 +210,7 @@ Source0: %{name}-%{version}.tar.gz %define tizen_feature_tvinputdevice_support 0 -%define tizen_feature_convergence_support 1 +%define tizen_feature_convergence_support 0 %endif # tizen_profile_mobile @@ -309,7 +309,7 @@ Source0: %{name}-%{version}.tar.gz %define tizen_feature_nbs_support 0 %endif -%define tizen_feature_convergence_support 1 +%define tizen_feature_convergence_support 0 %endif # tizen_profile_wearable @@ -367,7 +367,7 @@ Source0: %{name}-%{version}.tar.gz %define tizen_feature_wi_fi_support 1 %define tizen_feature_inputdevice_support 0 %define tizen_feature_tvinputdevice_support 1 -%define tizen_feature_convergence_support 1 +%define tizen_feature_convergence_support 0 %endif # tizen_profile_tv -- 2.7.4 From e309700d2c758ae19533a6691b867d763e02d5e7 Mon Sep 17 00:00:00 2001 From: Lukasz Bardeli Date: Fri, 2 Jun 2017 11:55:09 +0200 Subject: [PATCH 06/16] [Archive][Convergence][Sound] fix cppTest issue [verification] Code compiles without error Change-Id: Iee11cdaf9647103fa54ede1c00168413f747016b Signed-off-by: Lukasz Bardeli --- src/archive/un_zip_extract_request.cc | 2 +- src/convergence/convergence_service.cc | 6 ++++-- src/sound/sound_manager.cc | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/archive/un_zip_extract_request.cc b/src/archive/un_zip_extract_request.cc index 8e6a11b..bd3f4d5 100644 --- a/src/archive/un_zip_extract_request.cc +++ b/src/archive/un_zip_extract_request.cc @@ -420,7 +420,7 @@ PlatformResult UnZipExtractRequest::handleFileEntry() ExtractAllProgressCallback* extract_callback = NULL; if(m_callback->getCallbackType() == EXTRACT_ALL_PROGRESS_CALLBACK || m_callback->getCallbackType() == EXTRACT_ENTRY_PROGRESS_CALLBACK) { - extract_callback = static_cast(m_callback); + extract_callback = dynamic_cast(m_callback); extract_callback->startedExtractingFile(m_file_info.uncompressed_size); } diff --git a/src/convergence/convergence_service.cc b/src/convergence/convergence_service.cc index 29992d7..e875ead 100644 --- a/src/convergence/convergence_service.cc +++ b/src/convergence/convergence_service.cc @@ -40,7 +40,8 @@ ConvergenceService::ConvergenceService() : convergence_plugin_(nullptr) , device_(nullptr) , type_(CONV_SERVICE_NONE) - , service_handle_(nullptr) { + , service_handle_(nullptr) + , connection_state_(CONV_SERVICE_CONNECTION_STATE_NONE) { ScopeLogger(); } @@ -48,7 +49,8 @@ ConvergenceService::ConvergenceService(conv_device_h device, conv_service_e type : convergence_plugin_(convergence_plugin) , device_(device) , type_(type) - , service_handle_(nullptr) { + , service_handle_(nullptr) + , connection_state_(CONV_SERVICE_CONNECTION_STATE_NONE) { ScopeLogger(); } diff --git a/src/sound/sound_manager.cc b/src/sound/sound_manager.cc index b71dfb5..a55a3a7 100644 --- a/src/sound/sound_manager.cc +++ b/src/sound/sound_manager.cc @@ -124,8 +124,11 @@ std::string SoundManager::SoundIOTypeToString(sound_device_io_direction_e type) SoundManager::SoundManager(SoundInstance& instance) : is_volume_change_listener_(false), + volume_change_listener_id_(0), soundModeChangeListening(false), is_sound_device_change_listener_(false), + sound_device_connection_listener_id_(0), + sound_device_state_listener_id_(0), instance_(instance), soundModeListener(nullptr) { FillMaxVolumeMap(); -- 2.7.4 From 25eb5e1c6749cabdc8902742c072519486d5eeac Mon Sep 17 00:00:00 2001 From: Lukasz Bardeli Date: Wed, 7 Jun 2017 08:27:26 +0200 Subject: [PATCH 07/16] [Archive] checking if dynamic_cast succeeded [Verification] Code compiles without error Change-Id: Id48b95aaea1d69573a1e50acaa12304b338b8ef8 --- src/archive/un_zip_extract_request.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/archive/un_zip_extract_request.cc b/src/archive/un_zip_extract_request.cc index bd3f4d5..12ca6de 100644 --- a/src/archive/un_zip_extract_request.cc +++ b/src/archive/un_zip_extract_request.cc @@ -421,6 +421,10 @@ PlatformResult UnZipExtractRequest::handleFileEntry() if(m_callback->getCallbackType() == EXTRACT_ALL_PROGRESS_CALLBACK || m_callback->getCallbackType() == EXTRACT_ENTRY_PROGRESS_CALLBACK) { extract_callback = dynamic_cast(m_callback); + if( NULL == extract_callback) { + SLoggerE("extract_callback is null"); + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Could not create extracted file"); + } extract_callback->startedExtractingFile(m_file_info.uncompressed_size); } -- 2.7.4 From b53fb6809150b9279f031ebca739c1e252205982 Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Wed, 7 Jun 2017 08:47:54 +0200 Subject: [PATCH 08/16] [version] 1.86 Change-Id: Ifcc9c5bcf836582ab986f53808fdf1ec3ce14ce7 --- packaging/webapi-plugins.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index bf4febe..c3c7348 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -10,7 +10,7 @@ %define crosswalk_extensions_path %{_libdir}/%{crosswalk_extensions} Name: webapi-plugins -Version: 1.85 +Version: 1.86 Release: 0 License: Apache-2.0 and BSD-3-Clause and MIT Group: Development/Libraries -- 2.7.4 From 6b9c2ba596d9358e319717139a7c51c6de261563 Mon Sep 17 00:00:00 2001 From: Tomasz Marciniak Date: Wed, 7 Jun 2017 12:07:09 +0200 Subject: [PATCH 09/16] [Power] Restore system side brightness [Verification] Code compiles. TCT pass rate 100% (auto and manual) Now system side brightness is restored when application is closed/terminated. Change-Id: I9fe5a60c7f4f85e5ed9f891f16fb7e5cf57ee857 Signed-off-by: Tomasz Marciniak --- src/power/power_instance.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/power/power_instance.cc b/src/power/power_instance.cc index 8296123..746f21e 100755 --- a/src/power/power_instance.cc +++ b/src/power/power_instance.cc @@ -74,7 +74,13 @@ PowerInstance::PowerInstance() { PowerInstance::~PowerInstance() { LoggerD("Enter"); + PowerManager::GetInstance()->RemoveListener(this); + + PlatformResult result = PowerManager::GetInstance()->RestoreScreenBrightness(); + if (result.IsError()) { + LoggerE("Failed to restore brightness."); + } } enum PowerCallbacks { -- 2.7.4 From 530cedb1072c493c0c05098a46141b5134da9c9d Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Wed, 14 Jun 2017 07:26:56 +0200 Subject: [PATCH 10/16] [version] 1.87 Change-Id: Ic2a1806af385df069553fcdb38d57e362ff94c36 Signed-off-by: Piotr Kosko --- packaging/webapi-plugins.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index c3c7348..737966a 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -10,7 +10,7 @@ %define crosswalk_extensions_path %{_libdir}/%{crosswalk_extensions} Name: webapi-plugins -Version: 1.86 +Version: 1.87 Release: 0 License: Apache-2.0 and BSD-3-Clause and MIT Group: Development/Libraries -- 2.7.4 From 431444c47e8c19b7765ae2edcf2a37db02bb20b5 Mon Sep 17 00:00:00 2001 From: Pawel Wasowski Date: Thu, 22 Jun 2017 12:29:13 +0200 Subject: [PATCH 11/16] [SystemInfo] Fix for "BATTERY" property value change listener callbacks Callbacks called on "BATTERY" property value change threw an exception, if "lowThreshold" or "highThreshold" SystemInfoOptions were specified. [Verification] Tested in Chrome DevTools, registered callbacks work fine. Change-Id: Ie50dfb0710e9b203e072ff5336b77ff27c464031 Signed-off-by: Pawel Wasowski --- src/systeminfo/systeminfo_api.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/systeminfo/systeminfo_api.js b/src/systeminfo/systeminfo_api.js index 2e5dc4f..bb656c0 100644 --- a/src/systeminfo/systeminfo_api.js +++ b/src/systeminfo/systeminfo_api.js @@ -898,13 +898,13 @@ function _systeminfoBatteryListenerCallback(eventObj) { for (var watchId in callbacks) { if (callbacks.hasOwnProperty(watchId)) { var listener = callbacks[watchId]; + var propObj = !listener.isArrayType ? + _createProperty(property, eventObj.result.array[0]) : + _createPropertyArray(property, eventObj.result); var executeCall = (T_.isUndefined(listener.lowThreshold) || (propObj.level <= listener.lowThreshold)) || (T_.isUndefined(listener.highThreshold) || (propObj.level >= listener.highThreshold)); - var propObj = !listener.isArrayType ? - _createProperty(property, eventObj.result.array[0]) : - _createPropertyArray(property, eventObj.result); if (executeCall) { listener.callback(propObj); } -- 2.7.4 From 8cce89cd15716deacefede58942ea342009ad928 Mon Sep 17 00:00:00 2001 From: Lukasz Bardeli Date: Wed, 28 Jun 2017 08:24:32 +0200 Subject: [PATCH 12/16] [Application][Alarm] Free app_control_h using app_control_destroy [Verification] Code compiles without error. TCT passrate Alarm 100% AppControl 100% Application 100% Change-Id: I5c32e2307d9b7e8b36df0919c670c97b5828a572 --- src/alarm/alarm_utils.cc | 26 ++++++++++++++++++++------ src/application/application_utils.cc | 23 +++++++++++++++++------ 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/alarm/alarm_utils.cc b/src/alarm/alarm_utils.cc index 1c9ee9d..ba8872c 100755 --- a/src/alarm/alarm_utils.cc +++ b/src/alarm/alarm_utils.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include + #include "alarm_utils.h" #include "common/logger.h" @@ -34,9 +36,19 @@ PlatformResult AppControlToService(const picojson::object& obj, app_control_h *a return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "Invalid parameter passed."); } - app_control_create(app_control); + app_control_h app_control_tmp = nullptr; + int result = app_control_create(&app_control_tmp); + + if (APP_CONTROL_ERROR_NONE != result) { + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Creation AppControl failed.", + ("Problem with create handle.")); + } + + std::unique_ptr::type, int(*)(app_control_h)> app_control_ptr( + app_control_tmp, &app_control_destroy); + - int ret = app_control_set_operation(*app_control, it_operation->second.get().c_str()); + int ret = app_control_set_operation(app_control_tmp, it_operation->second.get().c_str()); if (APP_CONTROL_ERROR_NONE != ret) { return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Error while setting operation.", ("Failed app_control_set_operation(): %d (%s)", ret, get_error_message(ret))); @@ -44,7 +56,7 @@ PlatformResult AppControlToService(const picojson::object& obj, app_control_h *a const auto it_uri = obj.find("uri"); if (it_end != it_uri && it_uri->second.is()) { - ret = app_control_set_uri(*app_control, it_uri->second.get().c_str()); + ret = app_control_set_uri(app_control_tmp, it_uri->second.get().c_str()); if (APP_CONTROL_ERROR_NONE != ret) { return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Error while setting uri.", ("Failed app_control_set_uri(): %d (%s)", ret, get_error_message(ret))); @@ -53,7 +65,7 @@ PlatformResult AppControlToService(const picojson::object& obj, app_control_h *a const auto it_mime = obj.find("mime"); if (it_end != it_mime && it_mime->second.is()) { - ret = app_control_set_mime(*app_control, it_mime->second.get().c_str()); + ret = app_control_set_mime(app_control_tmp, it_mime->second.get().c_str()); if (APP_CONTROL_ERROR_NONE != ret) { return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Error while setting mime.", ("Failed app_control_set_mime(): %d (%s)", ret, get_error_message(ret))); @@ -62,7 +74,7 @@ PlatformResult AppControlToService(const picojson::object& obj, app_control_h *a const auto it_category = obj.find("category"); if (it_end != it_category && it_category->second.is()) { - ret = app_control_set_category(*app_control, it_category->second.get().c_str()); + ret = app_control_set_category(app_control_tmp, it_category->second.get().c_str()); if (APP_CONTROL_ERROR_NONE != ret) { return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Error while setting category.", ("Failed app_control_set_category(): %d (%s)", ret, get_error_message(ret))); @@ -75,7 +87,7 @@ PlatformResult AppControlToService(const picojson::object& obj, app_control_h *a PlatformResult result = PlatformResult(ErrorCode::NO_ERROR); for (auto iter = data.begin(); iter != data.end(); ++iter) { - result = AppControlToServiceExtraData(iter->get(), app_control); + result = AppControlToServiceExtraData(iter->get(), &app_control_tmp); if (!result) { LoggerE("Failed AppControlToServiceExtraData()"); return result; @@ -83,6 +95,8 @@ PlatformResult AppControlToService(const picojson::object& obj, app_control_h *a } } + *app_control = app_control_ptr.release(); + return PlatformResult(ErrorCode::NO_ERROR); } diff --git a/src/application/application_utils.cc b/src/application/application_utils.cc index a7860c1..8d56999 100644 --- a/src/application/application_utils.cc +++ b/src/application/application_utils.cc @@ -207,24 +207,33 @@ PlatformResult ApplicationUtils::ApplicationControlToService( return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "Invalid parameter was passed."); } - app_control_create(app_control); + app_control_h app_control_tmp = nullptr; + int result = app_control_create(&app_control_tmp); + + if (APP_CONTROL_ERROR_NONE != result) { + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Creation AppControl failed.", + ("Problem with create handle.")); + } + + std::unique_ptr::type, int(*)(app_control_h)> app_control_ptr( + app_control_tmp, &app_control_destroy); // operation - app_control_set_operation(*app_control, it_operation->second.get().c_str()); + app_control_set_operation(app_control_tmp, it_operation->second.get().c_str()); // uri if (it_uri->second.is()) { - app_control_set_uri(*app_control, it_uri->second.get().c_str()); + app_control_set_uri(app_control_tmp, it_uri->second.get().c_str()); } // mime if (it_mime->second.is()) { - app_control_set_mime(*app_control, it_mime->second.get().c_str()); + app_control_set_mime(app_control_tmp, it_mime->second.get().c_str()); } // category if (it_category->second.is()) { - app_control_set_category(*app_control, it_category->second.get().c_str()); + app_control_set_category(app_control_tmp, it_category->second.get().c_str()); } // ApplicationControlData @@ -233,7 +242,7 @@ PlatformResult ApplicationUtils::ApplicationControlToService( for (auto iter = data.begin(); iter != data.end(); ++iter) { if (iter->is()) { PlatformResult ret = - ApplicationControlDataToServiceExtraData(iter->get(), *app_control); + ApplicationControlDataToServiceExtraData(iter->get(), app_control_tmp); if (ret.IsError()) { LoggerE("Failed ApplicationControlDataToServiceExtraData()"); return ret; @@ -241,6 +250,8 @@ PlatformResult ApplicationUtils::ApplicationControlToService( } } + *app_control = app_control_ptr.release(); + return PlatformResult(ErrorCode::NO_ERROR); } -- 2.7.4 From 5d1ec94bd224dbde3b64ba124f8e6f2ad0bdd486 Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Wed, 28 Jun 2017 08:48:39 +0200 Subject: [PATCH 13/16] [version] 1.88 Change-Id: I8944a33b7b9421c481f988f09f753c668fae927c Signed-off-by: Piotr Kosko --- packaging/webapi-plugins.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index 737966a..e823e27 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -10,7 +10,7 @@ %define crosswalk_extensions_path %{_libdir}/%{crosswalk_extensions} Name: webapi-plugins -Version: 1.87 +Version: 1.88 Release: 0 License: Apache-2.0 and BSD-3-Clause and MIT Group: Development/Libraries -- 2.7.4 From 3b71b0bac5e1bb09c50c97168dba1619b3ed40d6 Mon Sep 17 00:00:00 2001 From: Jakub Skowron Date: Fri, 30 Jun 2017 16:02:34 +0200 Subject: [PATCH 14/16] [Utils] Fix privilege bypass, StringCopy function User could redefine String and String.indexOf to bypass privilege check and to go outside of virtual-root by ../ in path Change-Id: Ia9f7210ba685d1df18c9c443706361f624a38c1e Signed-off-by: Jakub Skowron --- src/filesystem/js/common.js | 2 ++ src/utils/utils_api.js | 66 ++++++++++++++++++++++++++++++--------------- 2 files changed, 46 insertions(+), 22 deletions(-) diff --git a/src/filesystem/js/common.js b/src/filesystem/js/common.js index adf52c7..e900cb3 100644 --- a/src/filesystem/js/common.js +++ b/src/filesystem/js/common.js @@ -169,6 +169,8 @@ var commonFS_ = (function() { } function checkPathWithoutDots(aPath) { + aPath = xwalk.utils.StringCopy(aPath); + if (-1 !== aPath.indexOf('/../')) { return false; } diff --git a/src/utils/utils_api.js b/src/utils/utils_api.js index 3c4d46e..b9a4a83 100644 --- a/src/utils/utils_api.js +++ b/src/utils/utils_api.js @@ -3,20 +3,26 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -//Object xwalk.JSON - guaranteed to not being modified by the application programmer -var JSON_ = {stringify: JSON.stringify, parse: JSON.parse}; -Object.freeze(JSON_); -exports.JSON = JSON_; +//We're in a function set up by XWALK which 'use strict' mode, +//so we use below function to get out of the strict mode to get global 'this' +var _global = (new Function('return this'))(); + +var shallow_copy_own_elements = function(orig) { + var copy = {}; + //copy only own properties + var names = Object.getOwnPropertyNames(orig); + for( var i in names ) { + var key = names[i] + copy[key] = orig[key]; + } + return copy; +}; -var _enableJsLogs = false; +//xwalk.JSON: guaranteed to not being modified by the application programmer +exports.JSON = shallow_copy_own_elements(JSON); +Object.freeze(exports.JSON); -var _global = {}; -if (typeof window != 'undefined') { - _global = window; -} -else if (typeof global != 'undefiend') { - _global = global; -} +var _enableJsLogs = false; /** * @deprecated Used only by validateArguments() @@ -146,6 +152,21 @@ function Utils() { }); } +var origString = String; +var StringPrototypeCopy = shallow_copy_own_elements(String.prototype); +Object.freeze(StringPrototypeCopy); + +var StringCopy = function(str) { + return Object.setPrototypeOf( new origString(str), StringPrototypeCopy ); +}; +StringCopy.fromCharCode = String.fromCharCode; +StringCopy.fromCodePoint = String.fromCodePoint; +StringCopy.raw = String.raw; +Object.freeze(StringCopy); + +//xwalk.utils.StringCopy: returns a sanitized version of String - user cannot modify its prototype +Utils.prototype.StringCopy = StringCopy; + Utils.prototype.error = console.error.bind(console); Utils.prototype.warn = console.warn.bind(console); Utils.prototype.log = _enableJsLogs ? console.log.bind(console) : function(){}; @@ -331,8 +352,9 @@ Type.prototype.isUndefined = function(obj) { }; Type.prototype.isA = function(obj, type) { - var clas = Object.prototype.toString.call(obj).slice(8, -1); - return (obj !== undefined) && (obj !== null) && (clas === type); + return obj !== undefined && obj !== null && + obj.constructor !== null && obj.constructor !== undefined && + obj.constructor.name === type; }; Type.prototype.isEmptyObject = function(obj) { @@ -475,7 +497,7 @@ Converter.prototype.toDouble = function(val, nullable) { }; function _toString(val) { - return String(val); + return StringCopy(val).toString(); } Converter.prototype.toString = function(val, nullable) { @@ -1018,7 +1040,7 @@ var NativeManager = function(extension) { }); extension_.setMessageListener(function(json) { - var msg = JSON_.parse(json); + var msg = exports.JSON.parse(json); var id; if (msg.hasOwnProperty(this.CALLBACK_ID_KEY)) { @@ -1082,7 +1104,7 @@ NativeManager.prototype.call = function(cmd, args, callback) { }; NativeManager.prototype.callSync = function(cmd, args) { - var request = JSON_.stringify({ + var request = exports.JSON.stringify({ cmd: cmd, args: args || {} }); @@ -1092,7 +1114,7 @@ NativeManager.prototype.callSync = function(cmd, args) { /* C++ extension didn't set sync response using Instance::SendSyncReply */ throw new WebAPIException(WebAPIException.ABORT_ERR, "Internal error"); } - return JSON_.parse(response); + return exports.JSON.parse(response); }; NativeManager.prototype.sendRuntimeMessage = function(msg, body) { @@ -1346,13 +1368,13 @@ var NativeBridge = (function (extension, debug) { var Bridge = function () {}; Bridge.prototype = { sync: function (data) { - var json = JSON_.stringify({ + var json = exports.JSON.stringify({ cmd: data.cmd, args: data }); if (debug) xwalk.utilss.log('bridge.sync, json: ' + json); var result = extension.internal.sendSyncMessage(json); - var obj = JSON_.parse(result); + var obj = exports.JSON.parse(result); if (obj.error) throw new WebAPIException(obj.code, obj.name, obj.message); return obj.result; @@ -1360,7 +1382,7 @@ var NativeBridge = (function (extension, debug) { async: function (data) { var l = new Listener(); data.cid = Listeners.getInstance().add(l); - var json = JSON_.stringify({ + var json = exports.JSON.stringify({ cmd: data.cmd, args: data }); @@ -1398,7 +1420,7 @@ var NativeBridge = (function (extension, debug) { */ if (debug) xwalk.utils.log('bridge.setMessageListener, json: ' + json); - var data = JSON_.parse(json); + var data = exports.JSON.parse(json); if (data.cid && data.action) { setTimeout(function() { Listeners.getInstance().resolve(data.cid, data.action, data.args, data.keep); -- 2.7.4 From d5bd447a6a340355b9fe73fef974e71c1d1a9866 Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Wed, 5 Jul 2017 09:10:11 +0200 Subject: [PATCH 15/16] [version] 1.89 Change-Id: Icf0dcfdfa530d3fad644cc560a00ea1933064188 Signed-off-by: Piotr Kosko --- packaging/webapi-plugins.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index e823e27..ad09fb8 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -10,7 +10,7 @@ %define crosswalk_extensions_path %{_libdir}/%{crosswalk_extensions} Name: webapi-plugins -Version: 1.88 +Version: 1.89 Release: 0 License: Apache-2.0 and BSD-3-Clause and MIT Group: Development/Libraries -- 2.7.4 From 4c236233a4dbfee12a27efcc30a25a442471d97c Mon Sep 17 00:00:00 2001 From: Szymon Jastrzebski Date: Fri, 7 Jul 2017 14:41:54 +0200 Subject: [PATCH 16/16] [Messaging] Replacing call of email_attachment_data_t structure constructor to calloc Native function email_free_attachment_data uses free() to release allocated memory pointing by tmp. Thus, we should call calloc() instead of structure's constructor. Messaging-email TCT passed 100%. Change-Id: Ib81f1da2e0270cfa76aef0eab7005d968c1f102c Signed-off-by: Szymon Jastrzebski --- src/messaging/message.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/messaging/message.cc b/src/messaging/message.cc index bdd7873..57703b1 100755 --- a/src/messaging/message.cc +++ b/src/messaging/message.cc @@ -591,7 +591,7 @@ PlatformResult addSingleEmailAttachment(std::shared_ptr message, PlatformResult ret = copyFileToTemp(att->getFilePath(), &dirPath); if (ret.IsError()) return ret; - email_attachment_data_t* tmp = new email_attachment_data_t(); + email_attachment_data_t* tmp = (email_attachment_data_t*)calloc(1, sizeof(email_attachment_data_t)); tmp->attachment_name = strdup(att->getShortFileName().c_str()); tmp->attachment_path = strdup(std::string(dirPath + "/" + att->getShortFileName()).c_str()); -- 2.7.4