summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Keeler <jacobkeeler@ymail.com>2018-05-09 14:19:18 -0700
committerJacob Keeler <jacobkeeler@ymail.com>2018-05-09 14:19:18 -0700
commitc1242d21ae65cf870453a46ea5fec0525ffc840f (patch)
tree79ca6ab43b590e85d9049da8854640670fd72dcb
parentdf9b67026d90f0f9cdf04bec7dd3c7666a25db87 (diff)
parent35d2403e4819a6d352a86cd3484e38eb69663cb2 (diff)
downloadsdl_core-c1242d21ae65cf870453a46ea5fec0525ffc840f.tar.gz
Merge remote-tracking branch 'origin/feature/ubuntu_16_04_linux_support' into test
-rw-r--r--src/components/security_manager/src/crypto_manager_impl.cc5
-rw-r--r--src/components/security_manager/test/ssl_context_test.cc59
-rw-r--r--src/components/utils/src/file_system.cc25
3 files changed, 49 insertions, 40 deletions
diff --git a/src/components/security_manager/src/crypto_manager_impl.cc b/src/components/security_manager/src/crypto_manager_impl.cc
index 6bee28a976..2cc88c5966 100644
--- a/src/components/security_manager/src/crypto_manager_impl.cc
+++ b/src/components/security_manager/src/crypto_manager_impl.cc
@@ -137,8 +137,13 @@ bool CryptoManagerImpl::Init() {
#endif
switch (get_settings().security_manager_protocol_name()) {
case SSLv3:
+#ifdef OPENSSL_NO_SSL3
+ LOG4CXX_WARN(logger_, "OpenSSL does not support SSL3 protocol");
+ return false;
+#else
method = is_server ? SSLv3_server_method() : SSLv3_client_method();
break;
+#endif
case TLSv1:
method = is_server ? TLSv1_server_method() : TLSv1_client_method();
break;
diff --git a/src/components/security_manager/test/ssl_context_test.cc b/src/components/security_manager/test/ssl_context_test.cc
index 945059e58c..a77cd98b27 100644
--- a/src/components/security_manager/test/ssl_context_test.cc
+++ b/src/components/security_manager/test/ssl_context_test.cc
@@ -228,7 +228,7 @@ class SSLTestParam : public testing::TestWithParam<ProtocolAndCipher> {
GetParam().server_ciphers_list);
const bool crypto_manager_initialization = crypto_manager->Init();
- EXPECT_TRUE(crypto_manager_initialization);
+ ASSERT_TRUE(crypto_manager_initialization);
mock_client_manager_settings_ = utils::MakeShared<
NiceMock<security_manager_test::MockCryptoManagerSettings> >();
@@ -241,7 +241,7 @@ class SSLTestParam : public testing::TestWithParam<ProtocolAndCipher> {
GetParam().client_ciphers_list);
const bool client_manager_initialization = client_manager->Init();
- EXPECT_TRUE(client_manager_initialization);
+ ASSERT_TRUE(client_manager_initialization);
server_ctx = crypto_manager->CreateSSLContext();
client_ctx = client_manager->CreateSSLContext();
@@ -261,9 +261,12 @@ class SSLTestParam : public testing::TestWithParam<ProtocolAndCipher> {
}
void TearDown() OVERRIDE {
- crypto_manager->ReleaseSSLContext(server_ctx);
- client_manager->ReleaseSSLContext(client_ctx);
-
+ if (crypto_manager) {
+ crypto_manager->ReleaseSSLContext(server_ctx);
+ }
+ if (client_manager) {
+ client_manager->ReleaseSSLContext(client_ctx);
+ }
delete crypto_manager;
delete client_manager;
}
@@ -303,10 +306,10 @@ class SSLTestParam : public testing::TestWithParam<ProtocolAndCipher> {
mock_crypto_manager_settings_;
utils::SharedPtr<NiceMock<security_manager_test::MockCryptoManagerSettings> >
mock_client_manager_settings_;
- security_manager::CryptoManager* crypto_manager;
- security_manager::CryptoManager* client_manager;
- security_manager::SSLContext* server_ctx;
- security_manager::SSLContext* client_ctx;
+ security_manager::CryptoManager* crypto_manager = NULL;
+ security_manager::CryptoManager* client_manager = NULL;
+ security_manager::SSLContext* server_ctx = NULL;
+ security_manager::SSLContext* client_ctx = NULL;
std::string certificate_data_base64_;
};
@@ -323,11 +326,15 @@ INSTANTIATE_TEST_CASE_P(
ProtocolAndCipher(security_manager::TLSv1_1,
security_manager::TLSv1_1,
kFordCipher,
- kFordCipher),
+ kFordCipher)
+#ifndef OPENSSL_NO_SSL3
+ ,
ProtocolAndCipher(security_manager::SSLv3,
security_manager::SSLv3,
kFordCipher,
- kFordCipher)));
+ kFordCipher)
+#endif
+ ));
INSTANTIATE_TEST_CASE_P(
IncorrectProtocolAndCiphers,
@@ -336,18 +343,10 @@ INSTANTIATE_TEST_CASE_P(
security_manager::TLSv1_1,
kFordCipher,
kFordCipher),
- ProtocolAndCipher(security_manager::TLSv1,
- security_manager::SSLv3,
- kFordCipher,
- kFordCipher),
ProtocolAndCipher(security_manager::TLSv1_1,
security_manager::TLSv1,
kFordCipher,
kFordCipher),
- ProtocolAndCipher(security_manager::TLSv1_1,
- security_manager::SSLv3,
- kFordCipher,
- kFordCipher),
ProtocolAndCipher(security_manager::TLSv1_2,
security_manager::TLSv1,
kFordCipher,
@@ -355,6 +354,16 @@ INSTANTIATE_TEST_CASE_P(
ProtocolAndCipher(security_manager::TLSv1_2,
security_manager::TLSv1_1,
kFordCipher,
+ kFordCipher)
+#ifndef OPENSSL_NO_SSL3
+ ,
+ ProtocolAndCipher(security_manager::TLSv1,
+ security_manager::SSLv3,
+ kFordCipher,
+ kFordCipher),
+ ProtocolAndCipher(security_manager::TLSv1_1,
+ security_manager::SSLv3,
+ kFordCipher,
kFordCipher),
ProtocolAndCipher(security_manager::TLSv1_2,
security_manager::SSLv3,
@@ -367,7 +376,9 @@ INSTANTIATE_TEST_CASE_P(
ProtocolAndCipher(security_manager::SSLv3,
security_manager::TLSv1_1,
kFordCipher,
- kFordCipher)));
+ kFordCipher)
+#endif
+ ));
TEST_F(SSLTest, OnTSL2Protocol_BrokenHandshake) {
ASSERT_EQ(security_manager::SSLContext::Handshake_Result_Success,
@@ -521,11 +532,15 @@ INSTANTIATE_TEST_CASE_P(
ProtocolAndCipher(security_manager::TLSv1_1,
security_manager::TLSv1_2,
kFordCipher,
- kFordCipher),
+ kFordCipher)
+#ifndef OPENSSL_NO_SSL3
+ ,
ProtocolAndCipher(security_manager::SSLv3,
security_manager::TLSv1_2,
kFordCipher,
- kFordCipher)));
+ kFordCipher)
+#endif
+ ));
TEST_P(SSLTestForTLS1_2, HandshakeFailed) {
ASSERT_EQ(security_manager::SSLContext::Handshake_Result_Success,
diff --git a/src/components/utils/src/file_system.cc b/src/components/utils/src/file_system.cc
index 62a91ad1f3..62a090550d 100644
--- a/src/components/utils/src/file_system.cc
+++ b/src/components/utils/src/file_system.cc
@@ -71,17 +71,14 @@ int64_t file_system::FileSize(const std::string& path) {
size_t file_system::DirectorySize(const std::string& path) {
size_t size = 0;
- int32_t return_code = 0;
DIR* directory = NULL;
- struct dirent dir_element_;
- struct dirent* dir_element = &dir_element_;
+
struct dirent* result = NULL;
struct stat file_info = {0};
directory = opendir(path.c_str());
if (NULL != directory) {
- return_code = readdir_r(directory, dir_element, &result);
- for (; NULL != result && 0 == return_code;
- return_code = readdir_r(directory, dir_element, &result)) {
+ result = readdir(directory);
+ for (; NULL != result; result = readdir(directory)) {
if (0 == strcmp(result->d_name, "..") ||
0 == strcmp(result->d_name, ".")) {
continue;
@@ -229,19 +226,15 @@ bool file_system::DeleteFile(const std::string& name) {
}
void file_system::remove_directory_content(const std::string& directory_name) {
- int32_t return_code = 0;
DIR* directory = NULL;
- struct dirent dir_element_;
- struct dirent* dir_element = &dir_element_;
struct dirent* result = NULL;
directory = opendir(directory_name.c_str());
if (NULL != directory) {
- return_code = readdir_r(directory, dir_element, &result);
+ result = readdir(directory);
- for (; NULL != result && 0 == return_code;
- return_code = readdir_r(directory, dir_element, &result)) {
+ for (; NULL != result; result = readdir(directory)) {
if (0 == strcmp(result->d_name, "..") ||
0 == strcmp(result->d_name, ".")) {
continue;
@@ -295,18 +288,14 @@ std::vector<std::string> file_system::ListFiles(
return listFiles;
}
- int32_t return_code = 0;
DIR* directory = NULL;
- struct dirent dir_element_;
- struct dirent* dir_element = &dir_element_;
struct dirent* result = NULL;
directory = opendir(directory_name.c_str());
if (NULL != directory) {
- return_code = readdir_r(directory, dir_element, &result);
+ result = readdir(directory);
- for (; NULL != result && 0 == return_code;
- return_code = readdir_r(directory, dir_element, &result)) {
+ for (; NULL != result; result = readdir(directory)) {
if (0 == strcmp(result->d_name, "..") ||
0 == strcmp(result->d_name, ".")) {
continue;