Fix build for boost 1.71 and new glibc-devel 62/230062/8
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Tue, 7 Apr 2020 09:04:56 +0000 (11:04 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Thu, 9 Apr 2020 19:11:52 +0000 (19:11 +0000)
- Boost::asio needs pthreads.
- Replace deprecated boost::signals with signals2.
- Replace deprecated boost::asio::io_service with
  boost::asio::executor/boost::asio::io_context.
- Silence compiler warnings
- Replace boost socket's native() with native_handle()
- Update socket paths

Change-Id: Ie4fde5239b42b3ba7bcadd40b46fe6b9b84ca66b

27 files changed:
TEECLib/src/teec_api.c
TEEStub/PropertyAccess/PropertyUtility.cpp
include/include/config.h
log/ta_log.c
packaging/tef-simulator.spec
pkgconfig/tef-simulator-devkit.pc.in
simulatordaemon/daemonctl/CMakeLists.txt
simulatordaemon/debugproxy/CMakeLists.txt
simulatordaemon/debugproxy/inc/AsyncEvent.h
simulatordaemon/debugproxy/inc/DebugproxySocket.h
simulatordaemon/debugproxy/inc/ProxySession.h
simulatordaemon/debugproxy/src/AsyncEvent.cpp
simulatordaemon/debugproxy/src/DebugproxySocket.cpp
simulatordaemon/debugproxy/src/ProxySession.cpp
simulatordaemon/debugproxy/src/main.cpp
simulatordaemon/inc/ConnectionSession.h
simulatordaemon/src/ConnectionSession.cpp
simulatordaemon/src/ControlConnectionHandler.cpp
simulatordaemon/src/Session.cpp
simulatordaemon/src/SimulatorDaemonServer.cpp
simulatordaemon/src/TABinaryManager/TAUnpack.cpp
simulatordaemon/src/TAFactory.cpp
simulatordaemon/src/TAInstance.cpp
simulatordaemon/src/UUIDConfigManager.cpp
ssflib/dep/swdss/source/secure_file.cpp
ssflib/inc/permission.h
ssflib/src/ssf_arithmetic.cpp

index 14a6e63d05fecffd015165e742488dec64645b95..6feba69b8457c4c019347e19e19f31e8e7d4d7fd 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2015-2019 Samsung Electronics Co., Ltd. All rights reserved
+ * Copyright (c) 2015-2020 Samsung Electronics Co., Ltd. All rights reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -623,7 +623,7 @@ TEEC_Result TEEC_InitializeContext(const char *name, TEEC_Context *context)
                return TEEC_ERROR_BAD_PARAMETERS;
        }
 
-       if (name) strncpy(ctx.TEEName, name, ctx.nameLength);
+       if (name) strcpy(ctx.TEEName, name);
 
        // Connect to Simulator Daemon as a client
        TEEC_Result conn_result = connectToServer(&(context_imp->sockfd));
index 085cdc82bcecd67b77d383da289491e4bd347c32..f9debc35bc4303b084f094bd95224363c0df263d 100644 (file)
@@ -1,5 +1,5 @@
 /**\r
- * Copyright (c) 2015-2017 Samsung Electronics Co., Ltd All Rights Reserved\r
+ * Copyright (c) 2015-2020 Samsung Electronics Co., Ltd All Rights Reserved\r
  *\r
  *    Licensed under the Apache License, Version 2.0 (the "License");\r
  *    you may not use this file except in compliance with the License.\r
@@ -121,9 +121,9 @@ TEE_Result PropertyUtility::convertToUUID(const PropertyValue& in,
                        out.clockSeqAndNode[i] = std::stoul(clockSeqStr.substr(i * 2, 2),\r
                                                            nullptr, 16);\r
                }\r
-       } catch (std::invalid_argument) {\r
+       } catch (const std::invalid_argument&) {\r
                return TEE_ERROR_BAD_FORMAT;\r
-       } catch (std::out_of_range) {\r
+       } catch (const std::out_of_range&) {\r
                return TEE_ERROR_BAD_FORMAT;\r
        }\r
        return TEE_SUCCESS;\r
index 8e956f23f79c1bcb8eb8fbf2c0a6422fbc063c74..c5e76ad2b349e72585d5be0ad481b0346e62e338 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2015-2018 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015-2020 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
 
 
 //keep in sync with systemd/tef-simulator.socket
-#define SIMDAEMON_SOCK_PATH "/var/run/simdaemon"
-#define SIMDAEMON_CTL_PATH "/var/run/simdaemonctl"
+#define SIMDAEMON_SOCK_PATH "/run/simdaemon"
+#define SIMDAEMON_CTL_PATH "/run/simdaemonctl"
 
-#define DEBUGPROXY_SOCK_PATH "/var/run/simdaemon-debugproxy"
+#define DEBUGPROXY_SOCK_PATH "/run/simdaemon-debugproxy"
 //TEEStub must have write access in this directory (creating socket per TA)
-#define TEE_TASOCK_ROOT "/var/run/"
+#define TEE_TASOCK_ROOT "/run/"
 
 // from manpages: For portable use, a shared memory object
 // should be identified by a name of the form /somename
index 3fd6c60bbafb60846a129373d6ad813fa5671200..8624db5314ae4f9b8a024e0dd7c61e68a884bcaa 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2015-2017 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015-2020 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -86,10 +86,8 @@ void setDebugLogLevelNum(const usr_log_level __level)
 
 void getDebugLogName(char* __name)
 {
-       if(__name != NULL) {
-               int length = strlen(log_label) + 1;
-               strncpy(__name, log_label, length);
-       }
+       if(__name != NULL)
+               strcpy(__name, log_label);
 }
 
 void setDebugLogName(const char* __name)
index c77d5dd710df9aa5a0c73e273ec43a1b1ddc63ca..169be7c7a18b0e4cb175c502c4b8a550a1d5d158 100644 (file)
@@ -12,7 +12,7 @@ BuildRequires: boost-devel
 BuildRequires: pkgconfig(dlog)
 BuildRequires: pkgconfig(openssl1.1)
 BuildRequires: pkgconfig(libsystemd-daemon)
-Requires: boost-coroutine boost-filesystem boost-program-options boost-regex boost-signals boost-system boost-thread
+Requires: boost-coroutine boost-filesystem boost-program-options boost-regex boost-system boost-thread
 Requires: tef-libteec
 
 %{?systemd_requires}
index 462c63da8b35b4fd6508d51e73a73e3cd98683af..0388408623d7287da80952b26a39b54d898270ff 100644 (file)
@@ -7,5 +7,5 @@ Name: tef-simulator-devkit
 Description: TEF Simulator TA development kit
 Version: @PKGCFG_VERSION@
 Requires: boost dlog
-Libs: -L${libdir} -lTEEStub -lTEEStubEx -ltef-simulator-ssflib -ltef-simulator-log -lboost_thread -lboost_filesystem -lboost_system -ldlog -lrt
+Libs: -L${libdir} -lTEEStub -lTEEStubEx -ltef-simulator-ssflib -ltef-simulator-log -lboost_thread -lboost_filesystem -lboost_system -ldlog -lrt -lpthread
 Cflags: -I${includedir}/
index 544f8436fd90f93e24159cbf622bf86b6cd3af22..143e6308b4d1ddd74aa5a2e547e2b3c1e9f20888 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+# Copyright (c) 2018 - 2020 Samsung Electronics Co., Ltd All Rights Reserved
 #
 #    Licensed under the Apache License, Version 2.0 (the "License");
 #    you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@ INCLUDE_DIRECTORIES(
     )
 
 TARGET_LINK_LIBRARIES(${TARGET_TEF_SIMULATOR_DAEMONCTL}
+    ${CMAKE_THREAD_LIBS_INIT}
     boost_system boost_program_options boost_regex
     )
 
index 8197799ed66d3b87e4c65f328a3d37fe6bc6421a..a7b0bf9fd747f194bcc15098c94fd09c88b06f03 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+# Copyright (c) 2018 - 2020 Samsung Electronics Co., Ltd All Rights Reserved
 #
 #    Licensed under the Apache License, Version 2.0 (the "License");
 #    you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@ LINK_DIRECTORIES(
 )
 
 TARGET_LINK_LIBRARIES(${TARGET_TEF_SIMULATOR_DEBUGPROXY}
-    boost_system boost_signals boost_coroutine pthread
+    boost_system boost_coroutine pthread
     ${TARGET_TEF_SIMULATOR_LOG}
     ${DEBUGPROXY_DEPS_LIBRARIES}
     )
index 5e2dfd2fcd0176c0895ad1fdfccdad50d9c969ef..9cfd84b95ad1df681bb805243fccdd6eef1e3df8 100644 (file)
@@ -5,10 +5,7 @@
 #include <memory>
 #include <boost/asio.hpp>
 #include <boost/asio/spawn.hpp>
-
-/* FIXME - signals is already deprecated and signals2 is not yet in the repo */
-#define BOOST_SIGNALS_NO_DEPRECATION_WARNING
-#include <boost/signals.hpp>
+#include <boost/signals2.hpp>
 
 #include "common.h"
 
  */
 class AsyncEvent {
 public:
-       AsyncEvent(boost::asio::io_service &io);
+       AsyncEvent(boost::asio::executor executor);
        void wait(yield_ctx yield);
        void set();
-       boost::signal<void ()> done_signal;
+       boost::signals2::signal<void ()> done_signal;
 private:
        boost::asio::deadline_timer timer;
 };
@@ -31,7 +28,7 @@ private:
 class EventList {
 public:
        typedef std::vector<std::shared_ptr<AsyncEvent>> Events;
-       EventList(Events events, boost::asio::io_service &io);
+       EventList(Events events, boost::asio::executor executor);
        ~EventList();
        EventList(const EventList &) = delete;
        EventList& operator=(const EventList &) = delete;
@@ -41,7 +38,7 @@ public:
 private:
        AsyncEvent event;
        Events awaited_on_events;
-       std::vector<boost::signals::connection> connections;
+       std::vector<boost::signals2::connection> connections;
 };
 
 #endif /* __ASYNC_EVENT_H__ */
index 316f239d5e9be19b4823e4ea11ea94897f797133..51a636a50b2df72494c334fb776f9e059c6e5839 100644 (file)
 class DebugproxySocket
 {
 public:
-       DebugproxySocket(int sock, boost::asio::io_service &io);
-       DebugproxySocket(std::string sock_path, boost::asio::io_service &io);
+       DebugproxySocket(int sock, boost::asio::io_context &io);
+       DebugproxySocket(std::string sock_path, boost::asio::io_context &io);
        void start_accept();
        void shutdown();
 private:
        void async_accept(yield_ctx yield);
        void handle_connection(std::shared_ptr<local_sock> local_sock,
                               yield_ctx yield);
-       boost::asio::io_service &io;
+       boost::asio::io_context &io;
        local::stream_protocol::acceptor acceptor;
        std::shared_ptr<AsyncEvent> quit_event;
 };
index 3799c71d3169f497873a2143eb961bc818de0db7..703a6ad109cc0bf22b5012957c5509b5e713348c 100644 (file)
@@ -16,7 +16,7 @@ public:
        ~ProxySession();
        void async_session(yield_ctx yield);
 private:
-       boost::asio::io_service &io();
+       boost::asio::executor executor();
        uint32_t read_forwarded_port(yield_ctx yield);
        void setup_port_socket(int port, yield_ctx yield);
        /* This might be scheduled after ProxySession is destroyed, so let's keep it static */
@@ -30,7 +30,7 @@ private:
        void close_session();
 
        std::shared_ptr<AsyncEvent> quit_event;
-       std::shared_ptr<local::stream_protocol::socket> local_socket;
+       std::shared_ptr<local_sock> local_socket;
        std::shared_ptr<tcp_sock> port_socket;
 
        static const boost::posix_time::seconds PORT_TIMEOUT;
index 62d83d0ee4f75b6ae4ae8223bc76fbba95e561f0..601aebed3af8884f76477e7bc81e44bdde56c382 100644 (file)
@@ -3,9 +3,9 @@
 #include "AsyncEvent.h"
 
 
-AsyncEvent::AsyncEvent(boost::asio::io_service &io)
+AsyncEvent::AsyncEvent(boost::asio::executor executor)
 : done_signal()
-, timer(io)
+, timer(executor)
 {
        this->timer.expires_at(boost::posix_time::pos_infin);
 }
@@ -27,8 +27,8 @@ void AsyncEvent::set()
 }
 
 EventList::EventList(EventList::Events events,
-                     boost::asio::io_service &io)
-: event(io)
+                     boost::asio::executor executor)
+: event(executor)
 , awaited_on_events(events)
 , connections()
 {
index 130eb50c530b640aae8cffe5eadfd6ba8a87715c..f2004b174b19c364586c92b1ada3e3a81e876fe5 100644 (file)
 #include "DebugproxySocket.h"
 #include "ProxySession.h"
 
-DebugproxySocket::DebugproxySocket(int sock, boost::asio::io_service &io)
+DebugproxySocket::DebugproxySocket(int sock, boost::asio::io_context &io)
 : io(io)
 , acceptor(io, local::stream_protocol(), sock)
-, quit_event(std::make_shared<AsyncEvent>(io))
+, quit_event(std::make_shared<AsyncEvent>(io.get_executor()))
 {}
 
-DebugproxySocket::DebugproxySocket(std::string sock_path, boost::asio::io_service &io)
+DebugproxySocket::DebugproxySocket(std::string sock_path, boost::asio::io_context &io)
 : io(io)
 , acceptor(io, sock_path)
-, quit_event(std::make_shared<AsyncEvent>(io))
+, quit_event(std::make_shared<AsyncEvent>(io.get_executor()))
 {}
 
 
@@ -38,7 +38,7 @@ void DebugproxySocket::async_accept(yield_ctx yield)
 {
        try {
                while(true) {
-                       auto sock = std::make_shared<local::stream_protocol::socket>(this->io);
+                       auto sock = std::make_shared<local::stream_protocol::socket>(this->io.get_executor());
                        this->acceptor.async_accept(*sock, yield);
                        boost::asio::spawn(
                                this->io,
index 8d3f19cd29e2d9e8f8883535cbb9a72108cbfe0e..cf71fd60802761f603a230440aebba217f695065 100644 (file)
@@ -14,7 +14,7 @@ ProxySession::ProxySession(std::shared_ptr<local_sock> local_socket,
                           std::shared_ptr<AsyncEvent> quit_event)
 : quit_event(quit_event)
 , local_socket(local_socket)
-, port_socket(std::make_shared<tcp_sock>(local_socket->get_io_service()))
+, port_socket(std::make_shared<tcp_sock>(local_socket->get_executor()))
 {}
 
 ProxySession::~ProxySession()
@@ -22,9 +22,9 @@ ProxySession::~ProxySession()
        this->close_session();
 }
 
-boost::asio::io_service &ProxySession::io()
+boost::asio::executor ProxySession::executor()
 {
-       return this->local_socket->get_io_service();
+       return this->local_socket->get_executor();
 }
 
 uint32_t ProxySession::read_forwarded_port(yield_ctx yield)
@@ -53,13 +53,13 @@ void ProxySession::stop_port_listening_at_timeout(
 void ProxySession::setup_port_socket(int port, yield_ctx yield)
 {
        ip::tcp::endpoint port_ep(ip::address::from_string("127.0.0.1"), port);
-       auto port_acceptor = std::make_shared<ip::tcp::acceptor>(this->io(), port_ep);
+       auto port_acceptor = std::make_shared<ip::tcp::acceptor>(this->executor(), port_ep);
        /* FIXME: We don't want to read data from local socket before
         * forwarding it, so checking if it closed while we're listening on the
         * port is difficult. Let's just timeout instead.
         */
-       auto timeout = std::make_shared<boost::asio::deadline_timer>(this->io());
-       boost::asio::spawn(this->io(), boost::bind(
+       auto timeout = std::make_shared<boost::asio::deadline_timer>(this->executor());
+       boost::asio::spawn(this->executor(), boost::bind(
                &ProxySession::stop_port_listening_at_timeout,
                timeout, port_acceptor, _1));
        try {
@@ -75,18 +75,18 @@ void ProxySession::setup_port_socket(int port, yield_ctx yield)
 std::shared_ptr<AsyncEvent> ProxySession::start_forwarding()
 {
        LOGD(MODULE_DEBUGPROXY, "(%p) Two-way forwarding started", this);
-       auto connection_lost_event = std::make_shared<AsyncEvent>(this->io());
+       auto connection_lost_event = std::make_shared<AsyncEvent>(this->executor());
        char tag[100];
 
        std::sprintf(tag, "(%p) local -> port", this);
        boost::asio::spawn(
-               this->io(),
+               this->executor(),
                boost::bind(&forward<local::stream_protocol, ip::tcp>,
                            this->local_socket, this->port_socket,
                            connection_lost_event, tag, _1));
        std::sprintf(tag, "(%p) port -> local", this);
        boost::asio::spawn(
-               this->io(),
+               this->executor(),
                boost::bind(&forward<ip::tcp, local::stream_protocol>,
                            this->port_socket, this->local_socket,
                            connection_lost_event, tag, _1));
@@ -102,7 +102,7 @@ void ProxySession::async_session(yield_ctx yield)
 
        EventList events(EventList::Events{this->quit_event,
                                           connection_lost_event},
-                        this->io());
+                        this->executor());
        events.wait_on_any(yield);
        LOGD(MODULE_DEBUGPROXY, "(%p) Received session end event", this);
 }
index 3b92ad6a38d86b5b6d43ff643b559e14c77f7789..5eb3a1b0df6bb9af76dbbc26b0d8493ea444496e 100644 (file)
@@ -24,7 +24,7 @@ int take_socket_from_systemd() {
 int main()
 {
        try {
-               boost::asio::io_service io;
+               boost::asio::io_context io;
                int sock = take_socket_from_systemd();
                DebugproxySocket socket = sock >= 0 ? DebugproxySocket(sock, io)
                                          : DebugproxySocket(DEBUGPROXY_SOCK_PATH, io);
index 80e50ac26a30c4ab9119e802db2fa2274a347f72..8ee707766c16e5a29491fd205858784afd8cd164 100644 (file)
@@ -59,11 +59,11 @@ private:
 public:
        pthread_mutex_t connLock;
        typedef boost::shared_ptr<ConnectionSession<header_t>> session_ptr;
-       static session_ptr create(boost::asio::io_service& io_service, handler_ptr handler)
+       static session_ptr create(boost::asio::executor executor, handler_ptr handler)
        {
-               return session_ptr(new ConnectionSession(io_service, handler));
+               return session_ptr(new ConnectionSession(executor, handler));
        }
-       ConnectionSession(boost::asio::io_service& io_service, handler_ptr handler);
+       ConnectionSession(boost::asio::executor executor, handler_ptr handler);
        stream_protocol::socket& socket()
        {
                return clientSocket;
index fbbf8ec22a34fbade86c63d1688bb6698a1861b6..cb90a9d8f3a4a894db0380249fe0c95c0245e235 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2015-2018 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015-2020 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -35,9 +35,9 @@
  *-----------------------------------------------------------------------------*/
 
 template<typename header_t>
-ConnectionSession<header_t>::ConnectionSession(boost::asio::io_service& io_service,
+ConnectionSession<header_t>::ConnectionSession(boost::asio::executor executor,
                                               handler_ptr handler):
-       m_handler(handler), clientSocket(io_service), clientData()
+       m_handler(handler), clientSocket(executor), clientData()
        {
                pthread_mutex_init(&connLock, NULL);
                currentState = CMD_READ;
@@ -51,7 +51,7 @@ ConnectionSession<header_t>::ConnectionSession(boost::asio::io_service& io_servi
  */
 template<typename header_t>
 void ConnectionSession<header_t>::start() {
-       m_handler->handleConnect(clientSocket.native());
+       m_handler->handleConnect(clientSocket.native_handle());
        currentState = CMD_READ;
 
        // read bytes to identify the command and execute callback when
index 77825701fdcf5b18b549ae92cfe3d1f2e0c3570f..122325fc86961290fe98f3ca54fb889d63bdf607 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2015-2018 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015-2020 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -125,7 +125,7 @@ void ControlConnectionHandler::handleQueryPortCommand(std::vector<char> &data)
        boost::optional<uint32_t> port;
        try {
                port = UUIDConfig->at(cmd.uuid)->getDebugPort();
-       } catch (std::out_of_range) {
+       } catch (const std::out_of_range&) {
                port = boost::none;
        }
 
index c06a9530cbd52c42362295761d20c541d1434b41..08f43b9521d7b3f382fce9e847ab5b5eacb9e71c 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2015-2018 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015-2020 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -113,7 +113,7 @@ TEEC_Result Session::createSession(OpenSessionData data) {
        try {
                auto confInfo = UUIDConf->at(data.uuid);
                runAsDebug = (confInfo->getDebugPort().is_initialized());
-       } catch (std::out_of_range) {   /* No special config set */
+       } catch (const std::out_of_range&) {    /* No special config set */
                runAsDebug = false;
        }
 
index c8b56c5e9cabbc0d4ff42625b3c464cb7c785616..9a3691dca53b29573e0dd5dc98b0ed1b8b3edc40 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2015-2018 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015-2020 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -59,7 +59,7 @@ void SimulatorDaemonServer::startTEEAccept()
                        new TEEConnectionHandler());
        ConnectionSession<int8_t>::session_ptr newSession =
                ConnectionSession<int8_t>::create(
-                       m_tee_acceptor->get_io_service(), teeHandler);
+                       m_tee_acceptor->get_executor(), teeHandler);
 
        m_tee_acceptor->async_accept(newSession->socket(),
                boost::bind(&SimulatorDaemonServer::handleTEEAccept, this, newSession,
@@ -72,7 +72,7 @@ void SimulatorDaemonServer::startCtlAccept()
                        new ControlConnectionHandler());
        ConnectionSession<enum ControlCommand>::session_ptr newSession =
                ConnectionSession<enum ControlCommand>::create(
-                       m_ctl_acceptor->get_io_service(), ctlHandler);
+                       m_ctl_acceptor->get_executor(), ctlHandler);
 
        m_ctl_acceptor->async_accept(newSession->socket(),
                boost::bind(&SimulatorDaemonServer::handleCtlAccept, this, newSession,
index ae8d2a0e751cff4b97584cfcf66845c5b88e19bb..d6be5c4a9e2aa2aaa44cf925684849a4b66e854b 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2015-2017 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015-2020 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -73,11 +73,11 @@ int TAUnpack::unpackTA(const string& path, const string& uuid) {
        string extract_dir_path = TEE_EXTRACT_ROOT + uuid + "-ext/";
        boost::system::error_code ec;
        fs::remove_all(extract_dir_path, ec);
-       if (ec != 0){
+       if (ec.failed()){
                LOGE(MODULE_SIM_DAEMON, "remove_all failed %s %s (trying to continue)", extract_dir_path.c_str(), ec.message().c_str());
        }
        fs::create_directory(extract_dir_path, ec);
-       if (ec != 0){
+       if (ec.failed()){
                LOGE(MODULE_SIM_DAEMON, "create_directory failed %s %s", extract_dir_path.c_str(), ec.message().c_str());
                return -1;
        }
index b4a2c12e19ed21dcf4a28b357bb90730201ff511..b229078a1b1f654f21e72b56c4e52a0d66f77bca 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2015-2018 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015-2020 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -376,7 +376,7 @@ bool TAFactory::launchTA(TEEC_UUID TAUUID, std::stringstream& str, pid_t& pid, b
        try {
                debugPort = UUIDConf->at(TAUUID)->getDebugPort();
                debug = true;
-       } catch (std::out_of_range) {
+       } catch (const std::out_of_range&) {
                debugPort = boost::none;
                debug = false;
        }
index c57e5f06ae19e63504d0340b38d5de48fccdb30a..b6b8b3bfb6773de1e531d1bfb1b4d41b5453d231 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2015-2017 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015-2020 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -357,7 +357,7 @@ int32_t TAInstance::setSocketOpt(struct timeval timeout) {
        if (isDebug == false) {
                LOGD(MODULE_SIM_DAEMON, "Entry");
                //Set socket timeout for mTAConnectionSocket
-               result = setsockopt(mTAConnectionSocket.native(), SOL_SOCKET, SO_RCVTIMEO,
+               result = setsockopt(mTAConnectionSocket.native_handle(), SOL_SOCKET, SO_RCVTIMEO,
                    (char*)&timeout, sizeof(timeout));
                if (result < 0) {
                        LOGE(MODULE_SIM_DAEMON, "setsockopt timeout = %d FAILED", timeout.tv_usec);
index 01acf4da9fd1c0c546d1cc3548af119dfa2fded6..ba87ea2b6b177815f13fecff6a4d129a3e1eb225 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2015-2018 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015-2020 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -52,7 +52,7 @@ std::shared_ptr<UUIDConfig> UUIDConfigManager::operator[](const TEEC_UUID &uuid)
        std::lock_guard<std::mutex> guard(m_mapLock);
        try {
                return m_TAMap.at(uuid);
-       } catch (std::out_of_range) {
+       } catch (const std::out_of_range&) {
                std::shared_ptr<UUIDConfig> newUUIDConf =
                        std::shared_ptr<UUIDConfig>(new UUIDConfig());
                m_TAMap[uuid] = newUUIDConf;
index c2de76f73b6bd56d794685e9ff5be4ce85971a2a..24c328c8109721b652b61b7f41134c804cae3937 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2013-2017 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2013-2020 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -484,7 +484,7 @@ int secure_file::derive_file_path() {
        m_full_path[SS_MAX_UUID_LEN] = '\0';
        remaining -= SS_MAX_UUID_LEN;
 
-       strncat(m_full_path, "/", 1);
+       strcat(m_full_path, "/");
        remaining -= 1;
 
        strncat(m_full_path, m_data_name, remaining - 1);
@@ -1393,7 +1393,8 @@ int secure_file::write(unsigned char* buffer, unsigned int buf_size,
                return SS_RET_DATA_SIZE_IS_TOO_BIG;
        }
 
-       memset(&m_file_content, 0, sizeof(m_file_content));
+       m_file_content = {};
+       memset(m_file_content.m_EncryptedKeyBuffer, 0, sizeof(m_file_content.m_EncryptedKeyBuffer));
 
        int iRet = prepare_data(&m_write_data, &m_write_data_size, buffer, buf_size,
            offset);
@@ -1465,7 +1466,8 @@ int secure_file::read(unsigned char** ret_buf, unsigned int* read_size,
        *read_size = 0;
 
        // cleaning internal file structure representation
-       memset(&m_file_content, 0, sizeof(m_file_content));
+       m_file_content = {};
+       memset(m_file_content.m_EncryptedKeyBuffer, 0, sizeof(m_file_content.m_EncryptedKeyBuffer));
 
        derive_file_path();
 
@@ -1636,7 +1638,8 @@ int secure_file::validate() {
        int ret = 0;
 
        // cleaning internal file structure representation
-       memset(&m_file_content, 0, sizeof(m_file_content));
+       m_file_content = {};
+       memset(m_file_content.m_EncryptedKeyBuffer, 0, sizeof(m_file_content.m_EncryptedKeyBuffer));
 
        // drive path
        derive_file_path();
@@ -1726,4 +1729,3 @@ int secure_file::get_data_name(char* data_name, int maxlen, bool is_dir) {
        return 0;
 }
 #endif
-
index bcc0ff2d5f3bef41a0c13cc04bbe028fc342d54a..f9ae07160a515238f74b76f65694ed534af80d67 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2011-2017 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2011-2020 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
                 LOGE(MODULE_SSF_LIB, "Permission Denied - Function %s() is not permitted." , __FUNCTION__);  \
                 return; }
 
+#define PERMISSION_CHECK_RETURN_BOOL(variable)      \
+        if (CheckPermission(variable)) { \
+               LOGE(MODULE_SSF_LIB, "Permission Denied - Function %s() is not permitted." , __FUNCTION__);  \
+               return false; }
+
 typedef enum {
         PERM_CRYPTO     = 0x00000001,
         PERM_STORAGE    = 0x00000002,
index 82483dafd7e21ea1d5b97034dca47a305f9face8..842b0c67851e4013fd1ee7b69da6e52811a1d47a 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2015-2017 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015-2020 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -264,7 +264,7 @@ void TEE_BigIntShiftRight(TEE_BigInt* destination_raw,
  * least significant bit
  */
 bool TEE_BigIntGetBit(const TEE_BigInt* object_raw, const uint32_t index) {
-       PERMISSION_CHECK(PERM_ARITHMETIC);
+       PERMISSION_CHECK_RETURN_BOOL(PERM_ARITHMETIC);
        SDRM_BIG_NUM *objBn = (SDRM_BIG_NUM*)object_raw;
        bool bitValue = (bool)SDRM_BN_num_bits_index(objBn, index);
        LOGD(TAG, "Success");
@@ -615,7 +615,7 @@ void TEE_BigIntInvMod(TEE_BigInt* dest, const TEE_BigInt* op,
  * @param op2 Pointer to the second operand
  */
 bool TEE_BigIntRelativePrime(const TEE_BigInt* op1, const TEE_BigInt* op2) {
-       PERMISSION_CHECK(PERM_ARITHMETIC);
+       PERMISSION_CHECK_RETURN_BOOL(PERM_ARITHMETIC);
        (void)op1;
        (void)op2;
        return false;