summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksandr Galiuzov <AGaliuzov@luxoft.com>2015-09-22 23:56:21 +0300
committerAleksandr Galiuzov <AGaliuzov@luxoft.com>2015-10-04 18:47:02 +0300
commit20b2fc038ba1ed5c6d6d882d525781c41a740ea2 (patch)
tree8100815577985c2e83dec77ebb174bdffd6de19e
parentf7496e763ed9de8d612e4bcf8578eda86a79fd62 (diff)
downloadsdl_core-20b2fc038ba1ed5c6d6d882d525781c41a740ea2.tar.gz
Add strict check for handshake result
Also commit contains additional logging for sql_query.cc file Closes-Bug: APPLINK-16239
-rw-r--r--src/components/policy/src/policy/policy_table/table_struct/types.cc12
-rw-r--r--src/components/policy/src/policy/policy_table/table_struct/types.h4
-rw-r--r--src/components/policy/src/policy/src/cache_manager.cc2
-rw-r--r--src/components/policy/src/policy/src/sql_pt_ext_representation.cc5
-rw-r--r--src/components/policy/src/policy/src/sql_pt_queries.cc6
-rw-r--r--src/components/security_manager/src/security_manager_impl.cc5
-rw-r--r--src/components/utils/src/qdb_wrapper/sql_query.cc5
7 files changed, 22 insertions, 17 deletions
diff --git a/src/components/policy/src/policy/policy_table/table_struct/types.cc b/src/components/policy/src/policy/policy_table/table_struct/types.cc
index f6135921b4..5d12f652b2 100644
--- a/src/components/policy/src/policy/policy_table/table_struct/types.cc
+++ b/src/components/policy/src/policy/policy_table/table_struct/types.cc
@@ -934,7 +934,7 @@ AppLevel::AppLevel()
: CompositeType(kUninitialized) {
}
-AppLevel::AppLevel(uint16_t minutes_in_hmi_full, const std::string& app_registration_language_gui, const std::string& app_registration_language_vui, uint16_t minutes_in_hmi_limited, uint16_t minutes_in_hmi_background, uint16_t minutes_in_hmi_none, uint16_t count_of_user_selections, uint16_t count_of_rejections_sync_out_of_memory, uint16_t count_of_rejections_nickname_mismatch, uint16_t count_of_rejections_duplicate_name, uint16_t count_of_rejected_rpc_calls, uint16_t count_of_rpcs_sent_in_hmi_none, uint16_t count_of_removals_for_bad_behavior, uint16_t count_of_tls_error, uint16_t count_of_run_attempts_while_revoked)
+AppLevel::AppLevel(uint16_t minutes_in_hmi_full, const std::string& app_registration_language_gui, const std::string& app_registration_language_vui, uint16_t minutes_in_hmi_limited, uint16_t minutes_in_hmi_background, uint16_t minutes_in_hmi_none, uint16_t count_of_user_selections, uint16_t count_of_rejections_sync_out_of_memory, uint16_t count_of_rejections_nickname_mismatch, uint16_t count_of_rejections_duplicate_name, uint16_t count_of_rejected_rpc_calls, uint16_t count_of_rpcs_sent_in_hmi_none, uint16_t count_of_removals_for_bad_behavior, uint16_t count_of_tls_errors, uint16_t count_of_run_attempts_while_revoked)
: CompositeType(kUninitialized),
minutes_in_hmi_full(minutes_in_hmi_full),
app_registration_language_gui(app_registration_language_gui),
@@ -949,7 +949,7 @@ AppLevel::AppLevel(uint16_t minutes_in_hmi_full, const std::string& app_registra
count_of_rejected_rpc_calls(count_of_rejected_rpc_calls),
count_of_rpcs_sent_in_hmi_none(count_of_rpcs_sent_in_hmi_none),
count_of_removals_for_bad_behavior(count_of_removals_for_bad_behavior),
- count_of_tls_error(count_of_tls_error),
+ count_of_tls_errors(count_of_tls_errors),
count_of_run_attempts_while_revoked(count_of_run_attempts_while_revoked) {
}
AppLevel::~AppLevel() {
@@ -969,7 +969,7 @@ AppLevel::AppLevel(const Json::Value* value__)
count_of_rejected_rpc_calls(impl::ValueMember(value__, "count_of_rejected_rpc_calls")),
count_of_rpcs_sent_in_hmi_none(impl::ValueMember(value__, "count_of_rpcs_sent_in_hmi_none")),
count_of_removals_for_bad_behavior(impl::ValueMember(value__, "count_of_removals_for_bad_behavior")),
- count_of_tls_error(impl::ValueMember(value__, "count_of_tls_error")),
+ count_of_tls_errors(impl::ValueMember(value__, "count_of_tls_errors")),
count_of_run_attempts_while_revoked(impl::ValueMember(value__, "count_of_run_attempts_while_revoked")) {
}
Json::Value AppLevel::ToJsonValue() const {
@@ -987,7 +987,7 @@ Json::Value AppLevel::ToJsonValue() const {
impl::WriteJsonField("count_of_rejected_rpc_calls", count_of_rejected_rpc_calls, &result__);
impl::WriteJsonField("count_of_rpcs_sent_in_hmi_none", count_of_rpcs_sent_in_hmi_none, &result__);
impl::WriteJsonField("count_of_removals_for_bad_behavior", count_of_removals_for_bad_behavior, &result__);
- impl::WriteJsonField("count_of_tls_error", count_of_tls_error, &result__);
+ impl::WriteJsonField("count_of_tls_errors", count_of_tls_errors, &result__);
impl::WriteJsonField("count_of_run_attempts_while_revoked", count_of_run_attempts_while_revoked, &result__);
return result__;
}
@@ -1031,7 +1031,7 @@ bool AppLevel::is_valid() const {
if (!count_of_removals_for_bad_behavior.is_valid()) {
return false;
}
- if (!count_of_tls_error.is_valid()) {
+ if (!count_of_tls_errors.is_valid()) {
return false;
}
if (!count_of_run_attempts_while_revoked.is_valid()) {
@@ -1089,7 +1089,7 @@ bool AppLevel::struct_empty() const {
if (count_of_removals_for_bad_behavior.is_initialized()) {
return false;
}
- if (count_of_tls_error.is_initialized()) {
+ if (count_of_tls_errors.is_initialized()) {
return false;
}
if (count_of_run_attempts_while_revoked.is_initialized()) {
diff --git a/src/components/policy/src/policy/policy_table/table_struct/types.h b/src/components/policy/src/policy/policy_table/table_struct/types.h
index d23d79e2df..2f5f275f0a 100644
--- a/src/components/policy/src/policy/policy_table/table_struct/types.h
+++ b/src/components/policy/src/policy/policy_table/table_struct/types.h
@@ -289,12 +289,12 @@ struct AppLevel : CompositeType {
Integer<uint16_t, 0, 65535> count_of_rejected_rpc_calls;
Integer<uint16_t, 0, 65535> count_of_rpcs_sent_in_hmi_none;
Integer<uint16_t, 0, 65535> count_of_removals_for_bad_behavior;
- Integer<uint16_t, 0, 65535> count_of_tls_error;
+ Integer<uint16_t, 0, 65535> count_of_tls_errors;
Integer<uint16_t, 0, 65535> count_of_run_attempts_while_revoked;
public:
AppLevel();
AppLevel(uint16_t minutes_in_hmi_full, const std::string& app_registration_language_gui, const std::string& app_registration_language_vui, uint16_t minutes_in_hmi_limited, uint16_t minutes_in_hmi_background, uint16_t minutes_in_hmi_none, uint16_t count_of_user_selections, uint16_t count_of_rejections_sync_out_of_memory, uint16_t count_of_rejections_nickname_mismatch, uint16_t count_of_rejections_duplicate_name, uint16_t count_of_rejected_rpc_calls, uint16_t count_of_rpcs_sent_in_hmi_none, uint16_t count_of_removals_for_bad_behavior,
-uint16_t count_of_tls_error, uint16_t count_of_run_attempts_while_revoked);
+uint16_t count_of_tls_errors, uint16_t count_of_run_attempts_while_revoked);
~AppLevel();
explicit AppLevel(const Json::Value* value__);
Json::Value ToJsonValue() const;
diff --git a/src/components/policy/src/policy/src/cache_manager.cc b/src/components/policy/src/policy/src/cache_manager.cc
index ac5729b424..29bbc74f57 100644
--- a/src/components/policy/src/policy/src/cache_manager.cc
+++ b/src/components/policy/src/policy/src/cache_manager.cc
@@ -934,7 +934,7 @@ void CacheManager::Increment(const std::string &app_id,
break;
case usage_statistics::COUNT_OF_TLS_ERRORS:
++(*pt_->policy_table.usage_and_error_counts->app_level)[app_id].
- count_of_tls_error;
+ count_of_tls_errors;
break;
default:
LOG4CXX_WARN(logger_, "Type app counter is unknown");
diff --git a/src/components/policy/src/policy/src/sql_pt_ext_representation.cc b/src/components/policy/src/policy/src/sql_pt_ext_representation.cc
index c413c654c9..1ce3b99ce8 100644
--- a/src/components/policy/src/policy/src/sql_pt_ext_representation.cc
+++ b/src/components/policy/src/policy/src/sql_pt_ext_representation.cc
@@ -1,5 +1,5 @@
-/*
- Copyright (c) 2013, Ford Motor Company
+/*
+ Copyright (c) 2015, Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -1497,6 +1497,7 @@ bool SQLPTExtRepresentation::SaveAppCounters(
query.Bind(12, it->second.count_of_run_attempts_while_revoked);
query.Bind(13, it->second.app_registration_language_gui);
query.Bind(14, it->second.app_registration_language_vui);
+ query.Bind(15, it->second.count_of_tls_errors);
if (!query.Exec() || !query.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into app level.");
return false;
diff --git a/src/components/policy/src/policy/src/sql_pt_queries.cc b/src/components/policy/src/policy/src/sql_pt_queries.cc
index 2e2fb92649..3d74b73f7a 100644
--- a/src/components/policy/src/policy/src/sql_pt_queries.cc
+++ b/src/components/policy/src/policy/src/sql_pt_queries.cc
@@ -1,5 +1,5 @@
-/*
- Copyright (c) 2013, " Ford Motor Company
+/*
+ Copyright (c) 2015, " Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, " with or without
@@ -528,7 +528,7 @@ const std::string kInsertAppLevel =
"`count_of_rejections_duplicate_name`,`count_of_rejected_rpcs_calls`,"
"`count_of_rpcs_sent_in_hmi_none`,`count_of_removals_for_bad_behavior`,"
"`count_of_run_attempts_while_revoked`,`app_registration_language_gui`,"
- "`app_registration_language_vui`) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+ "`app_registration_language_vui`, `count_of_tls_errors`) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
const std::string kDeleteSecondsBetweenRetries =
"DELETE FROM `seconds_between_retry`";
diff --git a/src/components/security_manager/src/security_manager_impl.cc b/src/components/security_manager/src/security_manager_impl.cc
index 16b63d304c..c88107c6e3 100644
--- a/src/components/security_manager/src/security_manager_impl.cc
+++ b/src/components/security_manager/src/security_manager_impl.cc
@@ -294,11 +294,10 @@ bool SecurityManagerImpl::ProccessHandshakeData(const SecurityMessage &inMessage
LOG4CXX_DEBUG(logger_, "SSL initialization finished success.");
NotifyListenersOnHandshakeDone(connection_key,
SSLContext::Handshake_Result_Success);
- } else if (handshake_result == SSLContext::Handshake_Result_Fail) {
+ } else if (handshake_result != SSLContext::Handshake_Result_Success){
// On handshake fail
LOG4CXX_WARN(logger_, "SSL initialization finished with fail.");
- NotifyListenersOnHandshakeDone(connection_key,
- SSLContext::Handshake_Result_Fail);
+ NotifyListenersOnHandshakeDone(connection_key, handshake_result);
}
if (out_data && out_data_size) {
diff --git a/src/components/utils/src/qdb_wrapper/sql_query.cc b/src/components/utils/src/qdb_wrapper/sql_query.cc
index 9dee7b22da..be90083865 100644
--- a/src/components/utils/src/qdb_wrapper/sql_query.cc
+++ b/src/components/utils/src/qdb_wrapper/sql_query.cc
@@ -35,10 +35,14 @@
#include <cassert>
#include <algorithm>
#include "qdb_wrapper/sql_database.h"
+#include "utils/logger.h"
+#include <errno.h>
namespace utils {
namespace dbms {
+ CREATE_LOGGERPTR_GLOBAL(logger_, "SQL query")
+
class SetBindInteger {
public:
explicit SetBindInteger(qdb_binding_t* array)
@@ -112,6 +116,7 @@ bool SQLQuery::Prepare(const std::string& query) {
query_ = query;
statement_ = qdb_stmt_init(db_->conn(), query.c_str(), query.length() + 1);
if (statement_ == -1) {
+ LOG4CXX_DEBUG(logger_, "Prepare error: " << strerror(errno));
error_ = Error::ERROR;
return false;
}