Cherrypicks from tizen_3.0 branch (HEAD: 6adc3ec) 22/115422/1
authorKyungwook Tak <k.tak@samsung.com>
Wed, 8 Feb 2017 04:14:20 +0000 (13:14 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Mon, 20 Feb 2017 01:46:42 +0000 (10:46 +0900)
Fix svace defects
(cherry picked from commit 2d3c97687a31b2a7d30979821be822dac67b79b6)

Restart service after test sample engine installed
(cherry picked from commit 074d22b0ec48f8657e56f0f3af5c1d0fa1dea09c)

Fix bug on CS sample engine
(cherry picked from commit 6adc3ec9be0e6b4e0e24bca85e7a0872f7d7c6ff)

Change-Id: Ibb820332ba178bdda953cf81de900286b0edbaa4
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
13 files changed:
packaging/csr-framework.spec
src/framework/common/credential.h
src/framework/db/cache.h
src/framework/service/cs-loader.h
src/framework/service/wp-loader.h
src/framework/ui/popup/popup.cpp
src/framework/ui/popup/popup.h
test/engine/content-screening/sample-engine.cpp
test/engine/web-protection/sample-engine.cpp
test/test-api-content-screening-async.cpp
test/test-api-content-screening.cpp
test/test-api-web-protection.cpp
test/test-helper.cpp

index 5943bdf..d561138 100644 (file)
@@ -245,6 +245,12 @@ fi
 
 %post -n %{name}-test
 chsmack -a "_" %{test_dir}/test_dir/dir1
+%if 0%{?with_sample_engine}
+systemctl stop %{service_name}-cs.socket
+systemctl stop %{service_name}-wp.socket
+systemctl stop %{service_name}-admin.socket
+systemctl restart %{service_name}.service
+%endif
 
 %files -f %{service_name}.lang
 %defattr(-,root,root,-)
index 9e35143..d70a42f 100644 (file)
@@ -30,8 +30,8 @@
 namespace Csr {
 
 struct API Credential {
-       uid_t uid;
-       gid_t gid;
+       uid_t uid = 0;
+       gid_t gid = 0;
        std::string label;
        std::string user;
        std::string client;
index 6bf2ec4..13520ad 100644 (file)
@@ -47,7 +47,7 @@ public:
        std::vector<std::string> filePaths;
        std::vector<CsDetectedPtr> detecteds;
        CsDetectedPtr riskiest;
-       time_t scanTime;
+       time_t scanTime = 0;
 };
 
 } // namespace Db
index 23088c8..d0b2c75 100644 (file)
@@ -88,28 +88,31 @@ private:
                                                                                 unsigned int *);
 
        struct PluginContext {
-               void *dlhandle;
-
-               FpGlobalInit fpGlobalInit;
-               FpGlobalDeinit fpGlobalDeinit;
-               FpContextCreate fpContextCreate;
-               FpContextDestroy fpContextDestroy;
-               FpScanData fpScanData;
-               FpScanFile fpScanFile;
-               FpScanAppOnCloud fpScanAppOnCloud;
-               FpScanAppOnCloudSupported fpScanAppOnCloudSupported;
-               FpGetSeverity fpGetSeverity;
-               FpGetMalwareName fpGetMalwareName;
-               FpGetDetailedUrl fpGetDetailedUrl;
-               FpGetErrorString fpGetErrorString;
-               FpGetEngineApiVersion fpGetEngineApiVersion;
-               FpGetEngineVendor fpGetEngineVendor;
-               FpGetEngineName fpGetEngineName;
-               FpGetEngineVersion fpGetEngineVersion;
-               FpGetEngineDataVersion fpGetEngineDataVersion;
-               FpGetEngineLatestUpdateTime fpGetEngineLatestUpdateTime;
-               FpGetEngineActivated fpGetEngineActivated;
-               FpGetEngineVendorLogo fpGetEngineVendorLogo;
+               PluginContext() {}
+               virtual ~PluginContext() {}
+
+               void *dlhandle = nullptr;
+
+               FpGlobalInit fpGlobalInit = nullptr;
+               FpGlobalDeinit fpGlobalDeinit = nullptr;
+               FpContextCreate fpContextCreate = nullptr;
+               FpContextDestroy fpContextDestroy = nullptr;
+               FpScanData fpScanData = nullptr;
+               FpScanFile fpScanFile = nullptr;
+               FpScanAppOnCloud fpScanAppOnCloud = nullptr;
+               FpScanAppOnCloudSupported fpScanAppOnCloudSupported = nullptr;
+               FpGetSeverity fpGetSeverity = nullptr;
+               FpGetMalwareName fpGetMalwareName = nullptr;
+               FpGetDetailedUrl fpGetDetailedUrl = nullptr;
+               FpGetErrorString fpGetErrorString = nullptr;
+               FpGetEngineApiVersion fpGetEngineApiVersion = nullptr;
+               FpGetEngineVendor fpGetEngineVendor = nullptr;
+               FpGetEngineName fpGetEngineName = nullptr;
+               FpGetEngineVersion fpGetEngineVersion = nullptr;
+               FpGetEngineDataVersion fpGetEngineDataVersion = nullptr;
+               FpGetEngineLatestUpdateTime fpGetEngineLatestUpdateTime = nullptr;
+               FpGetEngineActivated fpGetEngineActivated = nullptr;
+               FpGetEngineVendorLogo fpGetEngineVendorLogo = nullptr;
        };
 
        virtual void init(const std::string &, const std::string &, const std::string &) override;
index b926922..a371a50 100644 (file)
@@ -77,24 +77,27 @@ private:
                                                                                 unsigned int *);
 
        struct PluginContext {
-               void *dlhandle;
-
-               FpGlobalInit fpGlobalInit;
-               FpGlobalDeinit fpGlobalDeinit;
-               FpContextCreate fpContextCreate;
-               FpContextDestroy fpContextDestroy;
-               FpCheckUrl fpCheckUrl;
-               FpGetRiskLevel fpGetRiskLevel;
-               FPGetDetailedUrl fpGetDetailedUrl;
-               FpGetErrorString fpGetErrorString;
-               FpGetEngineApiVersion fpGetEngineApiVersion;
-               FpGetEngineVendor fpGetEngineVendor;
-               FpGetEngineName fpGetEngineName;
-               FpGetEngineVersion fpGetEngineVersion;
-               FpGetEngineDataVersion fpGetEngineDataVersion;
-               FpGetEngineLatestUpdateTime fpGetEngineLatestUpdateTime;
-               FpGetEngineActivated fpGetEngineActivated;
-               FpGetEngineVendorLogo fpGetEngineVendorLogo;
+               PluginContext() {}
+               virtual ~PluginContext() {}
+
+               void *dlhandle = nullptr;
+
+               FpGlobalInit fpGlobalInit = nullptr;
+               FpGlobalDeinit fpGlobalDeinit = nullptr;
+               FpContextCreate fpContextCreate = nullptr;
+               FpContextDestroy fpContextDestroy = nullptr;
+               FpCheckUrl fpCheckUrl = nullptr;
+               FpGetRiskLevel fpGetRiskLevel = nullptr;
+               FPGetDetailedUrl fpGetDetailedUrl = nullptr;
+               FpGetErrorString fpGetErrorString = nullptr;
+               FpGetEngineApiVersion fpGetEngineApiVersion = nullptr;
+               FpGetEngineVendor fpGetEngineVendor = nullptr;
+               FpGetEngineName fpGetEngineName = nullptr;
+               FpGetEngineVersion fpGetEngineVersion = nullptr;
+               FpGetEngineDataVersion fpGetEngineDataVersion = nullptr;
+               FpGetEngineLatestUpdateTime fpGetEngineLatestUpdateTime = nullptr;
+               FpGetEngineActivated fpGetEngineActivated = nullptr;
+               FpGetEngineVendorLogo fpGetEngineVendorLogo = nullptr;
        };
 
        virtual void init(const std::string &, const std::string &, const std::string &) override;
index 7c8d3ec..c7822f0 100644 (file)
@@ -48,7 +48,7 @@ void Popup::setSender(Sender &&sender)
        m_sender = std::move(sender);
 }
 
-Popup::Popup() : m_win(nullptr)
+Popup::Popup()
 {
        ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, keyDownCb, this);
 }
index b60bfc7..7bc2e85 100644 (file)
@@ -99,23 +99,23 @@ private:
        void setDefaultProperties(Evas_Object *obj) noexcept;
        void setRotationToWin(Evas_Object *obj) noexcept;
 
-       Evas_Object *m_win;
-       Evas_Object *m_popup;
-       Evas_Object *m_box;
-       Evas_Object *m_subBox;
-       Evas_Object *m_btnBox;
-       Evas_Object *m_header;
-       Evas_Object *m_body;
-       Evas_Object *m_footer;
-       Evas_Object *m_icon;
-       Evas_Object *m_hypertext;
+       Evas_Object *m_win = nullptr;
+       Evas_Object *m_popup = nullptr;
+       Evas_Object *m_box = nullptr;
+       Evas_Object *m_subBox = nullptr;
+       Evas_Object *m_btnBox = nullptr;
+       Evas_Object *m_header = nullptr;
+       Evas_Object *m_body = nullptr;
+       Evas_Object *m_footer = nullptr;
+       Evas_Object *m_icon = nullptr;
+       Evas_Object *m_hypertext = nullptr;
 
        std::string m_message;
        std::string m_iconPath;
        std::string m_hypertextUrl;
 
-       int m_winW;
-       int m_winH;
+       int m_winW = 0;
+       int m_winH = 0;
 
        Sender m_sender;
 
index 29634e8..aa7333d 100644 (file)
@@ -272,7 +272,7 @@ int csret_cs_compare_data(const RawBuffer &data, const std::string &needle)
        if (data.size() < needle.length())
                return -1;
 
-       for (size_t i = 0; i < data.size() - needle.length(); i++) {
+       for (size_t i = 0; i < data.size() - needle.length() + 1; i++) {
                bool isMatched = true;
 
                for (size_t j = 0; j < needle.length(); j++) {
index eb62909..e26288e 100644 (file)
@@ -167,26 +167,30 @@ int csret_wp_read_risky_urls(const std::string &path)
 
 int csret_wp_read_binary(const std::string &path, RawBuffer &buffer)
 {
-       std::ifstream f(path.c_str(), std::ios::binary);
+       try {
+               std::ifstream f(path.c_str(), std::ios::binary);
 
-       if (!f.is_open()) {
-               buffer.clear();
-               return CSRE_ERROR_NONE;
-       }
+               if (!f.is_open()) {
+                       buffer.clear();
+                       return CSRE_ERROR_NONE;
+               }
 
-       f.seekg(0, f.end);
-       auto len = f.tellg();
-       f.seekg(0, f.beg);
+               f.seekg(0, f.end);
+               auto len = f.tellg();
+               f.seekg(0, f.beg);
 
-       buffer.resize(len, 0);
-       f.read(reinterpret_cast<char *>(buffer.data()), buffer.size());
+               buffer.resize(len, 0);
+               f.read(reinterpret_cast<char *>(buffer.data()), buffer.size());
+
+               if (!f) {
+                       buffer.clear();
+                       return CSRET_WP_ERROR_FILE_IO;
+               }
 
-       if (!f) {
-               buffer.clear();
+               return CSRE_ERROR_NONE;
+       } catch (const std::exception &) {
                return CSRET_WP_ERROR_FILE_IO;
        }
-
-       return CSRE_ERROR_NONE;
 }
 
 int csret_wp_init_engine(csret_wp_engine_s **pengine)
@@ -194,7 +198,9 @@ int csret_wp_init_engine(csret_wp_engine_s **pengine)
        if (pengine == nullptr)
                return CSRE_ERROR_INVALID_PARAMETER;
 
-       auto ptr = new csret_wp_engine_s;
+       auto ptr = new (std::nothrow) csret_wp_engine_s;
+       if (ptr == nullptr)
+               return CSRE_ERROR_OUT_OF_MEMORY;
 
        ptr->vendorName = VENDOR_NAME;
        ptr->engineName = ENGINE_NAME;
@@ -261,15 +267,17 @@ int csre_wp_context_create(csre_wp_context_h *phandle)
        if (g_risky_urls.empty())
                return CSRE_ERROR_INVALID_HANDLE; // not yet initialized
 
-       csret_wp_engine_s *engine = nullptr;
-       auto ret = csret_wp_init_engine(&engine);
-       if (ret != CSRE_ERROR_NONE)
-               return ret;
-
        auto context = new (std::nothrow) csret_wp_context_s;
        if (context == nullptr)
                return CSRE_ERROR_OUT_OF_MEMORY;
 
+       csret_wp_engine_s *engine = nullptr;
+       auto ret = csret_wp_init_engine(&engine);
+       if (ret != CSRE_ERROR_NONE) {
+               delete context;
+               return ret;
+       }
+
        context->engine = engine;
 
        *phandle = reinterpret_cast<csre_wp_context_h>(context);
index 607241d..574fb3e 100644 (file)
@@ -60,31 +60,18 @@ struct AsyncTestContext {
        std::mutex m;
        std::mutex m_vec;
        std::condition_variable cv;
-       int scannedCnt;
-       int detectedCnt;
-       int completedCnt;
-       int cancelledCnt;
-       int errorCnt;
+       int scannedCnt = 0;
+       int detectedCnt = 0;
+       int completedCnt = 0;
+       int cancelledCnt = 0;
+       int errorCnt = 0;
        std::vector<std::string> scannedList;
        std::vector<csr_cs_malware_h> detectedList;
-       int errorCode;
-       bool apiReturned;
-
-       AsyncTestContext(bool raceTest) :
-               scannedCnt(0),
-               detectedCnt(0),
-               completedCnt(0),
-               cancelledCnt(0),
-               errorCnt(0),
-               apiReturned(!raceTest) {}
-
-       AsyncTestContext() :
-               scannedCnt(0),
-               detectedCnt(0),
-               completedCnt(0),
-               cancelledCnt(0),
-               errorCnt(0),
-               apiReturned(true) {}
+       int errorCode = 0;
+       bool apiReturned = true;
+
+       AsyncTestContext(bool raceTest) : apiReturned(!raceTest) {}
+       AsyncTestContext() {}
 
        bool isDone(void) const {
                return this->completedCnt != 0 || this->cancelledCnt != 0 || this->errorCnt != 0;
index 240af4e..6563d45 100644 (file)
@@ -39,7 +39,7 @@ namespace {
 
 void assertMalwareInList(csr_cs_malware_list_h list, size_t count, const std::string &filepath)
 {
-       csr_cs_malware_h malware;
+       csr_cs_malware_h malware = nullptr;
        for (size_t i = 0; i < count; i++) {
                ASSERT_SUCCESS(csr_cs_malware_list_get_malware(list, i, &malware));
                CHECK_IS_NOT_NULL(malware);
@@ -56,7 +56,7 @@ void assertMalwareInList(csr_cs_malware_list_h list, size_t count, const std::st
 
 void assertMalwareNotInList(csr_cs_malware_list_h list, size_t count, const std::string &filepath)
 {
-       csr_cs_malware_h malware;
+       csr_cs_malware_h malware = nullptr;
        for (size_t i = 0; i < count; i++) {
                ASSERT_SUCCESS(csr_cs_malware_list_get_malware(list, i, &malware));
                CHECK_IS_NOT_NULL(malware);
@@ -132,7 +132,7 @@ BOOST_AUTO_TEST_CASE(scan_data_normal)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected;
+       csr_cs_malware_h detected = nullptr;
        unsigned char data[100] = {0, };
 
        // no malware detected
@@ -149,7 +149,7 @@ BOOST_AUTO_TEST_CASE(scan_data_high)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected;
+       csr_cs_malware_h detected = nullptr;
        unsigned char data[100] = {0, };
        auto start_time = ::time(nullptr);
 
@@ -171,7 +171,7 @@ BOOST_AUTO_TEST_CASE(scan_data_medium)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected;
+       csr_cs_malware_h detected = nullptr;
        unsigned char data[100] = {0, };
        auto start_time = ::time(nullptr);
 
@@ -193,7 +193,7 @@ BOOST_AUTO_TEST_CASE(scan_data_low)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected;
+       csr_cs_malware_h detected = nullptr;
        unsigned char data[100] = {0, };
        auto start_time = ::time(nullptr);
 
@@ -215,7 +215,7 @@ BOOST_AUTO_TEST_CASE(scan_data_negative)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected;
+       csr_cs_malware_h detected = nullptr;
        unsigned char data[100] = {0, };
 
        ASSERT_IF(csr_cs_scan_data(nullptr, data, sizeof(data), &detected),
@@ -236,7 +236,7 @@ BOOST_AUTO_TEST_CASE(scan_file_normal)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected;
+       csr_cs_malware_h detected = nullptr;
 
        ASSERT_SUCCESS(csr_cs_scan_file(context, TEST_FILE_NORMAL, &detected));
 
@@ -252,7 +252,7 @@ BOOST_AUTO_TEST_CASE(scan_file_high)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected;
+       csr_cs_malware_h detected = nullptr;
        auto start_time = ::time(nullptr);
 
        Test::touch_file_assert(TEST_FILE_HIGH);
@@ -273,7 +273,7 @@ BOOST_AUTO_TEST_CASE(scan_file_medium)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected;
+       csr_cs_malware_h detected = nullptr;
        auto start_time = ::time(nullptr);
 
        Test::touch_file_assert(TEST_FILE_MEDIUM);
@@ -294,7 +294,7 @@ BOOST_AUTO_TEST_CASE(scan_file_low)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected;
+       csr_cs_malware_h detected = nullptr;
        auto start_time = ::time(nullptr);
 
        Test::touch_file_assert(TEST_FILE_LOW);
@@ -315,7 +315,7 @@ BOOST_AUTO_TEST_CASE(scan_file_media_dir)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected;
+       csr_cs_malware_h detected = nullptr;
        auto start_time = ::time(nullptr);
 
        Test::remove_file(TEST_FILE_MEDIA());
@@ -337,7 +337,7 @@ BOOST_AUTO_TEST_CASE(scan_file_tmp_dir)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected;
+       csr_cs_malware_h detected = nullptr;
        auto start_time = ::time(nullptr);
 
        Test::remove_file(TEST_FILE_TMP);
@@ -360,7 +360,7 @@ BOOST_AUTO_TEST_CASE(scan_file_wgt_dir)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected;
+       csr_cs_malware_h detected = nullptr;
        auto start_time = ::time(nullptr);
 
        Test::uninstall_app(TEST_WGT_PKG_ID);
@@ -385,7 +385,7 @@ BOOST_AUTO_TEST_CASE(scan_file_tpk_dir)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected;
+       csr_cs_malware_h detected = nullptr;
        auto start_time = ::time(nullptr);
 
        Test::uninstall_app(TEST_TPK_PKG_ID);
@@ -409,7 +409,7 @@ BOOST_AUTO_TEST_CASE(scan_file_invalid_params)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected;
+       csr_cs_malware_h detected = nullptr;
 
        ASSERT_IF(csr_cs_scan_file(nullptr, TEST_FILE_NORMAL, &detected),
                          CSR_ERROR_INVALID_HANDLE);
@@ -426,7 +426,7 @@ BOOST_AUTO_TEST_CASE(scan_file_not_existing_file)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected;
+       csr_cs_malware_h detected = nullptr;
 
        ASSERT_IF(csr_cs_scan_file(context, TEST_FILE_NO_EXIST, &detected),
                          CSR_ERROR_FILE_DO_NOT_EXIST);
@@ -440,8 +440,8 @@ BOOST_AUTO_TEST_CASE(get_detected_malware)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected;
-       csr_cs_malware_h stored;
+       csr_cs_malware_h detected = nullptr;
+       csr_cs_malware_h stored = nullptr;
 
        ASSERT_SUCCESS(csr_cs_scan_file(context, TEST_FILE_MEDIUM, &detected));
        CHECK_IS_NOT_NULL(detected);
@@ -460,7 +460,7 @@ BOOST_AUTO_TEST_CASE(get_detected_malware_invalid_param)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h stored;
+       csr_cs_malware_h stored = nullptr;
 
        ASSERT_IF(csr_cs_get_detected_malware(nullptr, TEST_FILE_MEDIUM, &stored),
                          CSR_ERROR_INVALID_HANDLE);
@@ -478,7 +478,7 @@ BOOST_AUTO_TEST_CASE(get_detected_malware_not_existing_file)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h stored;
+       csr_cs_malware_h stored = nullptr;
 
        ASSERT_SUCCESS(csr_cs_get_detected_malware(context, TEST_FILE_NO_EXIST, &stored));
        CHECK_IS_NULL(stored);
@@ -492,9 +492,10 @@ BOOST_AUTO_TEST_CASE(get_detected_malwares)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_list_h detected_list;
-       csr_cs_malware_h detected_high, detected_medium;
-       csr_cs_malware_h stored;
+       csr_cs_malware_list_h detected_list = nullptr;
+       csr_cs_malware_h detected_high = nullptr;
+       csr_cs_malware_h detected_medium = nullptr;
+       csr_cs_malware_h stored = nullptr;
        Test::ScopedCstr file_path_actual;
        size_t cnt = 0;
        size_t idx = 0;
@@ -541,7 +542,7 @@ BOOST_AUTO_TEST_CASE(get_detected_malwares_invalid_params)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_list_h detected_list;
+       csr_cs_malware_list_h detected_list = nullptr;
        size_t cnt = 0;
 
        const char *dirs[1] = {
@@ -575,7 +576,7 @@ BOOST_AUTO_TEST_CASE(get_detected_malwares_not_existing_dir)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_list_h detected_list;
+       csr_cs_malware_list_h detected_list = nullptr;
        size_t cnt = 0;
 
        const char *dirs[1] = {
@@ -597,7 +598,8 @@ BOOST_AUTO_TEST_CASE(get_ignored_malware)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected, stored;
+       csr_cs_malware_h detected = nullptr;
+       csr_cs_malware_h stored = nullptr;
 
        ASSERT_SUCCESS(csr_cs_scan_file(context, TEST_FILE_HIGH, &detected));
        CHECK_IS_NOT_NULL(detected);
@@ -622,7 +624,7 @@ BOOST_AUTO_TEST_CASE(get_ignored_malware_invalid_param)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h stored;
+       csr_cs_malware_h stored = nullptr;
 
        ASSERT_IF(csr_cs_get_ignored_malware(nullptr, TEST_FILE_MEDIUM, &stored),
                          CSR_ERROR_INVALID_HANDLE);
@@ -640,7 +642,7 @@ BOOST_AUTO_TEST_CASE(get_ignored_malware_not_existing_file)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h stored;
+       csr_cs_malware_h stored = nullptr;
 
        ASSERT_SUCCESS(csr_cs_get_ignored_malware(context, TEST_FILE_NO_EXIST, &stored));
        CHECK_IS_NULL(stored);
@@ -654,8 +656,10 @@ BOOST_AUTO_TEST_CASE(get_ignored_malwares)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_list_h ignored_list;
-       csr_cs_malware_h detected_high, detected_medium, stored;
+       csr_cs_malware_list_h ignored_list = nullptr;
+       csr_cs_malware_h detected_high = nullptr;
+       csr_cs_malware_h detected_medium = nullptr;
+       csr_cs_malware_h stored = nullptr;
        size_t cnt = 0;
        size_t idx = 0;
        size_t compared_cnt = 0;
@@ -712,7 +716,7 @@ BOOST_AUTO_TEST_CASE(get_ignored_malwares_invalid_params)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_list_h ignored_list;
+       csr_cs_malware_list_h ignored_list = nullptr;
        size_t cnt = 0;
 
        const char *dirs[1] = {
@@ -745,7 +749,7 @@ BOOST_AUTO_TEST_CASE(get_ignored_malwares_not_existing_dir)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_list_h ignored_list;
+       csr_cs_malware_list_h ignored_list = nullptr;
        size_t cnt = 0;
 
        const char *dirs[1] = {
@@ -767,7 +771,8 @@ BOOST_AUTO_TEST_CASE(judge_detected_malware)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected, stored;
+       csr_cs_malware_h detected = nullptr;
+       csr_cs_malware_h stored = nullptr;
 
        // remove earlier test results
        Test::copy_file(TEST_FILE_HIGH, TEST_FILE_MEDIA());
@@ -821,7 +826,7 @@ BOOST_AUTO_TEST_CASE(judge_detected_malware_after_changed_file)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected;
+       csr_cs_malware_h detected = nullptr;
 
        // scan and judge after touch
        Test::copy_file(TEST_FILE_HIGH, TEST_FILE_MEDIA());
@@ -851,7 +856,8 @@ BOOST_AUTO_TEST_CASE(judge_detected_malware_ignored_rescan)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected, stored;
+       csr_cs_malware_h detected = nullptr;
+       csr_cs_malware_h stored = nullptr;
 
        // remove earlier test results
        Test::copy_file(TEST_FILE_HIGH, TEST_FILE_MEDIA());
@@ -888,7 +894,8 @@ BOOST_AUTO_TEST_CASE(judge_detected_malware_remove_file)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected, stored;
+       csr_cs_malware_h detected = nullptr;
+       csr_cs_malware_h stored = nullptr;
 
        // remove earlier test results
        Test::copy_file(TEST_FILE_HIGH, TEST_FILE_MEDIA());
@@ -946,7 +953,7 @@ BOOST_AUTO_TEST_CASE(judge_detected_malware_remove_wgt)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected;
+       csr_cs_malware_h detected = nullptr;
 
        // remove old test data
        Test::uninstall_app(TEST_WGT_PKG_ID);
@@ -968,7 +975,7 @@ BOOST_AUTO_TEST_CASE(judge_detected_malware_remove_tpk)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected;
+       csr_cs_malware_h detected = nullptr;
 
        // remove old test data
        Test::uninstall_app(TEST_TPK_PKG_ID);
@@ -989,7 +996,7 @@ BOOST_AUTO_TEST_CASE(judge_detected_malware_invalid_params)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected;
+       csr_cs_malware_h detected = nullptr;
 
        ASSERT_SUCCESS(csr_cs_scan_file(context, TEST_FILE_HIGH, &detected));
        CHECK_IS_NOT_NULL(detected);
@@ -1011,7 +1018,7 @@ BOOST_AUTO_TEST_CASE(get_malware_after_file_removed)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h malware;
+       csr_cs_malware_h malware = nullptr;
 
        Test::remove_file(TEST_FILE_MEDIA());
        Test::copy_file_assert(TEST_FILE_HIGH, TEST_FILE_MEDIA());
@@ -1019,7 +1026,7 @@ BOOST_AUTO_TEST_CASE(get_malware_after_file_removed)
        ASSERT_SUCCESS(csr_cs_scan_file(context, TEST_FILE_MEDIA(), &malware));
        CHECK_IS_NOT_NULL(malware);
 
-       csr_cs_malware_h malware_stored;
+       csr_cs_malware_h malware_stored = nullptr;
        ASSERT_SUCCESS(csr_cs_get_detected_malware(context, TEST_FILE_MEDIA(), &malware_stored));
        CHECK_IS_NOT_NULL(malware_stored);
 
@@ -1037,7 +1044,7 @@ BOOST_AUTO_TEST_CASE(get_malwares_after_file_removed)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h malware;
+       csr_cs_malware_h malware = nullptr;
 
        Test::remove_file(TEST_FILE_MEDIA());
        Test::remove_file(TEST_FILE_TMP_IN_DIR_MALWARES);
@@ -1054,8 +1061,8 @@ BOOST_AUTO_TEST_CASE(get_malwares_after_file_removed)
                TEST_DIR_MALWARES
        };
 
-       csr_cs_malware_list_h malware_list;
-       size_t list_count;
+       csr_cs_malware_list_h malware_list = nullptr;
+       size_t list_count = 0;
        ASSERT_SUCCESS(csr_cs_get_detected_malwares(context, dirs, 2, &malware_list, &list_count));
        ::assertMalwareInList(malware_list, list_count, TEST_FILE_MEDIA());
        ::assertMalwareInList(malware_list, list_count, TEST_FILE_TMP_IN_DIR_MALWARES);
@@ -1076,7 +1083,7 @@ BOOST_AUTO_TEST_CASE(get_malware_after_file_changed)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h malware;
+       csr_cs_malware_h malware = nullptr;
 
        Test::remove_file(TEST_FILE_MEDIA());
        Test::copy_file_assert(TEST_FILE_HIGH, TEST_FILE_MEDIA());
@@ -1084,7 +1091,7 @@ BOOST_AUTO_TEST_CASE(get_malware_after_file_changed)
        ASSERT_SUCCESS(csr_cs_scan_file(context, TEST_FILE_MEDIA(), &malware));
        CHECK_IS_NOT_NULL(malware);
 
-       csr_cs_malware_h malware_stored;
+       csr_cs_malware_h malware_stored = nullptr;
        ASSERT_SUCCESS(csr_cs_get_detected_malware(context, TEST_FILE_MEDIA(), &malware_stored));
        CHECK_IS_NOT_NULL(malware_stored);
 
@@ -1105,7 +1112,7 @@ BOOST_AUTO_TEST_CASE(get_malwares_after_file_changed)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h malware;
+       csr_cs_malware_h malware = nullptr;
 
        Test::remove_file(TEST_FILE_MEDIA());
        Test::remove_file(TEST_FILE_TMP_IN_DIR_MALWARES);
@@ -1122,8 +1129,8 @@ BOOST_AUTO_TEST_CASE(get_malwares_after_file_changed)
                TEST_DIR_MALWARES
        };
 
-       csr_cs_malware_list_h malware_list;
-       size_t list_count;
+       csr_cs_malware_list_h malware_list = nullptr;
+       size_t list_count = 0;
        ASSERT_SUCCESS(csr_cs_get_detected_malwares(context, dirs, 2, &malware_list, &list_count));
 
        ::assertMalwareInList(malware_list, list_count, TEST_FILE_MEDIA());
@@ -1149,7 +1156,7 @@ BOOST_AUTO_TEST_CASE(get_ignored_malware_after_file_removed)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h malware;
+       csr_cs_malware_h malware = nullptr;
 
        Test::remove_file(TEST_FILE_MEDIA());
        Test::copy_file_assert(TEST_FILE_HIGH, TEST_FILE_MEDIA());
@@ -1157,7 +1164,7 @@ BOOST_AUTO_TEST_CASE(get_ignored_malware_after_file_removed)
        ASSERT_SUCCESS(csr_cs_scan_file(context, TEST_FILE_MEDIA(), &malware));
        CHECK_IS_NOT_NULL(malware);
 
-       csr_cs_malware_h malware_stored;
+       csr_cs_malware_h malware_stored = nullptr;
        ASSERT_SUCCESS(csr_cs_get_detected_malware(context, TEST_FILE_MEDIA(), &malware_stored));
        CHECK_IS_NOT_NULL(malware_stored);
 
@@ -1183,7 +1190,7 @@ BOOST_AUTO_TEST_CASE(get_ignored_malwares_after_file_removed)
        Test::copy_file_assert(TEST_FILE_HIGH, TEST_FILE_MEDIA());
        Test::copy_file_assert(TEST_FILE_HIGH, TEST_FILE_TMP_IN_DIR_MALWARES);
 
-       csr_cs_malware_h malware_tmp[2];
+       csr_cs_malware_h malware_tmp[2] = { nullptr, nullptr };
        ASSERT_SUCCESS(csr_cs_scan_file(context, TEST_FILE_MEDIA(), &malware_tmp[0]));
        CHECK_IS_NOT_NULL(malware_tmp[0]);
        ASSERT_SUCCESS(csr_cs_scan_file(context, TEST_FILE_TMP_IN_DIR_MALWARES, &malware_tmp[1]));
@@ -1194,8 +1201,8 @@ BOOST_AUTO_TEST_CASE(get_ignored_malwares_after_file_removed)
                TEST_DIR_MALWARES
        };
 
-       csr_cs_malware_list_h malware_list;
-       size_t list_count;
+       csr_cs_malware_list_h malware_list = nullptr;
+       size_t list_count = 0;
        ASSERT_SUCCESS(csr_cs_get_detected_malwares(context, dirs, 2, &malware_list, &list_count));
        ::assertMalwareInList(malware_list, list_count, TEST_FILE_MEDIA());
        ::assertMalwareInList(malware_list, list_count, TEST_FILE_TMP_IN_DIR_MALWARES);
@@ -1219,7 +1226,7 @@ BOOST_AUTO_TEST_CASE(get_ignored_malware_after_file_changed)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h malware;
+       csr_cs_malware_h malware = nullptr;
 
        Test::remove_file(TEST_FILE_MEDIA());
        Test::copy_file_assert(TEST_FILE_HIGH, TEST_FILE_MEDIA());
@@ -1227,7 +1234,7 @@ BOOST_AUTO_TEST_CASE(get_ignored_malware_after_file_changed)
        ASSERT_SUCCESS(csr_cs_scan_file(context, TEST_FILE_MEDIA(), &malware));
        CHECK_IS_NOT_NULL(malware);
 
-       csr_cs_malware_h malware_stored;
+       csr_cs_malware_h malware_stored = nullptr;
        ASSERT_SUCCESS(csr_cs_get_detected_malware(context, TEST_FILE_MEDIA(), &malware_stored));
        CHECK_IS_NOT_NULL(malware_stored);
 
@@ -1269,8 +1276,8 @@ BOOST_AUTO_TEST_CASE(get_ignored_malwares_after_file_changed)
                TEST_DIR_MALWARES
        };
 
-       csr_cs_malware_list_h malware_list;
-       size_t list_count;
+       csr_cs_malware_list_h malware_list = nullptr;
+       size_t list_count = 0;
        ASSERT_SUCCESS(csr_cs_get_detected_malwares(context, dirs, 2, &malware_list, &list_count));
        ::assertMalwareInList(malware_list, list_count, TEST_FILE_MEDIA());
        ::assertMalwareInList(malware_list, list_count, TEST_FILE_TMP_IN_DIR_MALWARES);
@@ -1325,7 +1332,7 @@ BOOST_AUTO_TEST_CASE(scan_file_wgt_dir_remove_app)
 
        auto c = Test::Context<csr_cs_context_h>();
        auto context = c.get();
-       csr_cs_malware_h detected;
+       csr_cs_malware_h detected = nullptr;
 
        Test::uninstall_app(TEST_WGT_PKG_ID);
        ASSERT_INSTALL_APP(TEST_WGT_PATH, TEST_WGT_TYPE);
index 90ea021..3d81a7f 100644 (file)
@@ -120,7 +120,7 @@ BOOST_AUTO_TEST_CASE(check_url_high)
        auto c = Test::Context<csr_wp_context_h>();
        auto context = c.get();
 
-       csr_wp_check_result_h result;
+       csr_wp_check_result_h result = nullptr;
        ASSERT_SUCCESS(csr_wp_check_url(context, RISK_HIGH_URL, &result));
 
        CHECK_IS_NOT_NULL(result);
@@ -137,7 +137,7 @@ BOOST_AUTO_TEST_CASE(check_url_medium)
        auto c = Test::Context<csr_wp_context_h>();
        auto context = c.get();
 
-       csr_wp_check_result_h result;
+       csr_wp_check_result_h result = nullptr;
        ASSERT_SUCCESS(csr_wp_check_url(context, RISK_MEDIUM_URL, &result));
 
        CHECK_IS_NOT_NULL(result);
@@ -154,7 +154,7 @@ BOOST_AUTO_TEST_CASE(check_url_low)
        auto c = Test::Context<csr_wp_context_h>();
        auto context = c.get();
 
-       csr_wp_check_result_h result;
+       csr_wp_check_result_h result = nullptr;
        ASSERT_SUCCESS(csr_wp_check_url(context, RISK_LOW_URL, &result));
 
        CHECK_IS_NOT_NULL(result);
@@ -171,7 +171,7 @@ BOOST_AUTO_TEST_CASE(check_url_unverified)
        auto c = Test::Context<csr_wp_context_h>();
        auto context = c.get();
 
-       csr_wp_check_result_h result;
+       csr_wp_check_result_h result = nullptr;
        ASSERT_SUCCESS(csr_wp_check_url(context, RISK_UNVERIFIED_URL, &result));
 
        CHECK_IS_NOT_NULL(result);
@@ -189,7 +189,7 @@ BOOST_AUTO_TEST_CASE(check_url_invalid_param)
        auto c = Test::Context<csr_wp_context_h>();
        auto context = c.get();
 
-       csr_wp_check_result_h result;
+       csr_wp_check_result_h result = nullptr;
        ASSERT_IF(csr_wp_check_url(nullptr, RISK_HIGH_URL, &result), CSR_ERROR_INVALID_HANDLE);
        ASSERT_IF(csr_wp_check_url(context, nullptr, &result), CSR_ERROR_INVALID_PARAMETER);
        ASSERT_IF(csr_wp_check_url(context, RISK_HIGH_URL, nullptr),
@@ -206,7 +206,7 @@ BOOST_AUTO_TEST_CASE(get_risk_level)
        auto context = c.get();
        csr_wp_risk_level_e risk_level;
 
-       csr_wp_check_result_h result;
+       csr_wp_check_result_h result = nullptr;
        ASSERT_SUCCESS(csr_wp_check_url(context, RISK_HIGH_URL, &result));
        ASSERT_SUCCESS(csr_wp_result_get_risk_level(result, &risk_level));
 
@@ -223,7 +223,7 @@ BOOST_AUTO_TEST_CASE(get_risk_level_invalid_param)
        auto context = c.get();
        csr_wp_risk_level_e risk_level;
 
-       csr_wp_check_result_h result;
+       csr_wp_check_result_h result = nullptr;
        ASSERT_SUCCESS(csr_wp_check_url(context, RISK_HIGH_URL, &result));
 
        ASSERT_IF(csr_wp_result_get_risk_level(result, nullptr), CSR_ERROR_INVALID_PARAMETER);
@@ -242,7 +242,7 @@ BOOST_AUTO_TEST_CASE(get_detailed_url)
 
        Test::ScopedCstr detailed_url;
 
-       csr_wp_check_result_h result;
+       csr_wp_check_result_h result = nullptr;
        ASSERT_SUCCESS(csr_wp_check_url(context, RISK_HIGH_URL, &result));
 
        ASSERT_SUCCESS(csr_wp_result_get_detailed_url(result, &detailed_url.ptr));
@@ -260,7 +260,7 @@ BOOST_AUTO_TEST_CASE(get_detailed_url_invalid_param)
 
        Test::ScopedCstr detailed_url;
 
-       csr_wp_check_result_h result;
+       csr_wp_check_result_h result = nullptr;
        ASSERT_SUCCESS(csr_wp_check_url(context, RISK_HIGH_URL, &result));
 
        ASSERT_IF(csr_wp_result_get_detailed_url(nullptr, &detailed_url.ptr),
index 508cbd5..5f81e35 100644 (file)
@@ -98,8 +98,8 @@ void ASSERT_DETECTED_HANDLE(csr_cs_malware_h expected, csr_cs_malware_h actual)
        csr_cs_severity_level_e e_severity, a_severity;
        Test::ScopedCstr e_malware_name, e_detailed_url, e_file_name, e_pkg_id;
        Test::ScopedCstr a_malware_name, a_detailed_url, a_file_name, a_pkg_id;
-       time_t e_timestamp, a_timestamp;
-       bool e_is_app, a_is_app;
+       time_t e_timestamp = 0, a_timestamp = 0;
+       bool e_is_app = true, a_is_app = true;
 
        ASSERT_SUCCESS(csr_cs_malware_get_severity(expected, &e_severity));
        ASSERT_SUCCESS(csr_cs_malware_get_name(expected, &e_malware_name.ptr));