summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCollin <iCollin@users.noreply.github.com>2019-08-28 16:30:42 -0400
committerGitHub <noreply@github.com>2019-08-28 16:30:42 -0400
commit0d41f149005218b9e5d76f6e40b892ecbc2e4280 (patch)
treedebe4e8f239c0362747ac2495ff0bd22fd33822a
parent75768a68f8bf22ddfc6a06fac2d799a74da0ce83 (diff)
downloadsdl_core-0d41f149005218b9e5d76f6e40b892ecbc2e4280.tar.gz
Fix/reject register too many requests (#2993)
* still init the RAI when we cannot find a session for the connection send a response to mobile when it tries to register no matter what * style script
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
index b39e50b222..419f1ca0c5 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
@@ -192,7 +192,7 @@ RegisterAppInterfaceRequest::~RegisterAppInterfaceRequest() {}
bool RegisterAppInterfaceRequest::Init() {
LOG4CXX_AUTO_TRACE(logger_);
- return GetDataOnSessionKey(connection_key(), &device_handle_, &device_id_);
+ return true;
}
void RegisterAppInterfaceRequest::Run() {
@@ -226,6 +226,23 @@ void RegisterAppInterfaceRequest::Run() {
return;
}
+ // Cache the original app ID (for legacy behavior)
+ const auto policy_app_id =
+ application_manager_.GetCorrectMobileIDFromMessage(message_);
+
+ if (application_manager_.IsApplicationForbidden(connection_key(),
+ policy_app_id)) {
+ SendResponse(false, mobile_apis::Result::TOO_MANY_PENDING_REQUESTS);
+ return;
+ }
+
+ if (!GetDataOnSessionKey(connection_key(), &device_handle_, &device_id_)) {
+ SendResponse(false,
+ mobile_apis::Result::GENERIC_ERROR,
+ "Could not find a session for your connection key!");
+ return;
+ }
+
LOG4CXX_DEBUG(
logger_,
"device_handle: " << device_handle_ << " device_id: " << device_id_);
@@ -234,10 +251,6 @@ void RegisterAppInterfaceRequest::Run() {
return;
}
- // Cache the original app ID (for legacy behavior)
- const auto policy_app_id =
- application_manager_.GetCorrectMobileIDFromMessage(message_);
-
ApplicationSharedPtr application =
application_manager_.application(device_id_, policy_app_id);
@@ -267,11 +280,6 @@ void RegisterAppInterfaceRequest::Run() {
::tolower);
(*message_)[strings::msg_params][strings::full_app_id] = new_app_id_full;
}
- if (application_manager_.IsApplicationForbidden(connection_key(),
- policy_app_id)) {
- SendResponse(false, mobile_apis::Result::TOO_MANY_PENDING_REQUESTS);
- return;
- }
if (IsApplicationWithSameAppIdRegistered()) {
SendResponse(false, mobile_apis::Result::DISALLOWED);