Improving comments and replace pg_strlcpy by privacy_guard_utils 60/149960/10 accepted/tizen/unified/20170920.081040 submit/tizen/20170919.011823
authorKyoungyong Lee <k.y.lee@samsung.com>
Mon, 4 Sep 2017 04:39:41 +0000 (13:39 +0900)
committerSaulo Aldighieri Moraes <s.moraes@samsung.com>
Mon, 18 Sep 2017 20:17:36 +0000 (17:17 -0300)
Change-Id: I3094d5094ad91a64179ceb2ab5a8c19c94382033

29 files changed:
ahocorasick/ahocorasick.c
ahocorasick/ahocorasick.h
client/CMakeLists.txt
client/inc/DlpLogsManager.h
client/inc/DlpPacketParser.h
client/inc/DlpPacketParserResult.h
client/inc/DlpRulesManager.h
client/inc/PrivacyGuardClient.h
client/inc/privacy_guard_client_internal.h
client/src/DlpLogsManager.cpp
client/src/DlpRulesManager.cpp
client/src/privacy_guard_client.cpp
common/inc/SocketConnection.h
common/inc/Utils.h
common/inc/privacy_guard_utils.h [new file with mode: 0644]
common/src/privacy_guard_utils.c [moved from common/src/pg_strlcpy.c with 90% similarity]
include/privacy_guard_client.h
include/privacy_guard_client_types.h
include/privacy_guard_dlp.h
server/CMakeLists.txt
server/inc/DlpPrivacyInfoData.h
server/inc/DlpRuleChangeNotification.h
server/inc/PrivacyGuardDb.h
server/inc/PrivacyInfoService.h
server/src/PrivacyGuardDb.cpp
server/src/service/DlpPrivacyInfoData.cpp
server/src/service/PrivacyInfoService.cpp
test/CMakeLists.txt
test/tc-privacy-guard.c

index e4e1ac3..6673b9b 100644 (file)
@@ -22,7 +22,7 @@
 #include <stdlib.h>
 #include "node.h"
 
-ac_instance *ahocorasick_init()
+ac_instance *ahocorasick_init(void)
 {
        ac_instance *ac = (ac_instance *)malloc(sizeof(ac_instance));
        memset(ac, 0, sizeof(ac_instance));
index 2c87847..bceaafe 100644 (file)
@@ -29,7 +29,7 @@ extern "C" {
 #endif
 
 /**
- * @fn                                 ac_instance *ahocorasick_init()
+ * @fn                                 ac_instance *ahocorasick_init(void)
  * @brief                              Create a new aho-corasick instance. It should freed with ahocorasick_free() when no longer needed.
  * @return                             The new instance
  * @callgraph
index 116a8fe..482a238 100755 (executable)
@@ -47,7 +47,7 @@ SET(PRIVACY_GUARD_CLIENT_SOURCES
        ${common_src_dir}/PrivacyIdInfo.cpp
        ${common_src_dir}/DlpUtils.cpp
        ${common_src_dir}/Utils.cpp
-       ${common_src_dir}/pg_strlcpy.c
+       ${common_src_dir}/privacy_guard_utils.c
        ${client_src_dir}/SocketClient.cpp
        ${client_src_dir}/PrivacyChecker.cpp
        ${client_src_dir}/PrivacyGuardClient.cpp
index 0c948f9..b24b9c6 100644 (file)
  *    limitations under the License.
  */
 
+/**
+ * @file       DlpLogsManager.h
+ * @brief      Manages the packet parsing and logging of leaks for a DLP client
+ */
+
 #ifndef _DLPLOGSMANAGER_H_
 #define _DLPLOGSMANAGER_H_
 
@@ -49,7 +54,7 @@ private:
 
        /**
         * @fn                                  static void *LeakLogSendThreadFunc(void *_this)
-        * @brief                               Set the rules for the packet parser
+        * @brief                               Create the thread which transmits leak logs to the DLP server
         *
         * @param[in] _this             Pointer to the object
         */
@@ -57,7 +62,7 @@ private:
 
        /**
         * @fn                                  PgDlpResult ParseAndLogLeakNow(leak_log_queue_entry_s &entry)
-        * @brief                               Set the rules for the packet parser
+        * @brief                               Parse the data and add any matches to the list for sending to the server
         *
         * @param[in] entry             The leaked information to be verified
         *
@@ -69,6 +74,19 @@ private:
 
 public:
        static DlpLogsManager *getInstance(void);
+
+       /**
+        * @brief                               Check the data packet for leaks and log any matches with the DLP server
+        *
+        * @param[in] hostname          The DNS name of the host to which the data is being transmitted
+        * @param[in] mem               The (binary) data packet to be checked
+        * @param[in] len               The length of the data packet in bytes
+        * @param[in] rules             The rules to use when parsing the data
+        *
+        * @return                      The overall action to be taken given the individual results,
+        *                              either PRIV_GUARD_DLP_RESULT_ALLOW (all results allow or sanitize),
+        *                              or PRIV_GUARD_DLP_RESULT_DENY.
+        */
        PgDlpResult ParseAndLogLeak(const char *hostname, char *mem, size_t len, const current_rules_list &rules);
 
 protected:
index 8cd3f5f..2f4781b 100644 (file)
@@ -37,7 +37,7 @@ public:
         * @brief                               Set the rules for the packet parser
         *
         * @param[in] rules             Pointer to a std::list of current_rules_s.
-        *                      The rules are not copied so they must remain valid while parsePacket() and getAction() are called.
+        *                      The rules are not copied so they must remain valid while parsePacket() or sanitize() is called.
         *
         * @return                              count of rules in the list
         */
@@ -47,10 +47,10 @@ public:
         * @fn                                  PgDlpResult parsePacket(char * const pdata, size_t length, DlpPacketParserResultList &rl)
         * @brief                               Parse a packet of data and return a std::list of DlpPacketParserResult.
         *                              Before calling this it is necessary to set rules (once) with setRules().
-        *                              After calling this you should call getResult() to sanitize the packet.
+        *                              After calling this you may call sanitize() to sanitize the packet.
         *
         * @param[in]  pdata    pointer to the packet data to be parsed. If sanitization is to be performed,
-        *                      the data must not be freed until after getResult() is called.
+        *                      the data must not be freed until after sanitize() is called.
         * @param[in]  length   byte length of the packet data to be parsed
         * @param[out] rl       std::list of DlpPacketParserResult. List may be empty.
         *
@@ -65,7 +65,7 @@ public:
         * @brief                               Get the overall action given a list of DlpPacketParserResult.
         *
         * @param[in]  pdata    pointer to the packet data to be parsed. If sanitization is to be performed,
-        *                              the data must not be freed until after getResult() is called.
+        *                              the data must not be freed until after sanitize() is called.
         * @param[in]  length   byte length of the packet data to be parsed
         * @param[in]  rl               std::list of DlpPacketParserResult. List may be empty.
         *
index 329cf74..37cca85 100644 (file)
@@ -16,7 +16,7 @@
 
 /**
  * @file       DlpPacketParserResult.h
- * @brief      Definitions for PrivacyGuardDLPPacketParserResult class and related things.
+ * @brief      Definitions for the DlpPacketParserResult class and related things.
  */
 
 #ifndef __DLP_PACKET_PARSER_RESULT_H__
index eb1a5b5..eb9892b 100644 (file)
  *    limitations under the License.
  */
 
+/**
+ * @file       DlpRulesManager.h
+ * @brief      Manages the packet parsing rules for a client
+ */
+
 #ifndef _DLPRULESMANAGER_H_
 #define _DLPRULESMANAGER_H_
 
@@ -39,10 +44,17 @@ private:
 
 public:
        static DlpRulesManager *getInstance(void);
+
+       /**
+        * @brief                               get the current rules as cached for the client
+        *
+        * @return                              a std::list of rules for the client
+        * @since                               Tizen 4.0
+        */
        std::list<current_rules_s> PgGetDlpCurrentRules();
 
 protected:
-   virtual void *NewRulesNotificationThread();
+       virtual void *NewRulesNotificationThread();
 };
 
 #endif // _DLPRULESMANAGER_H_
index 79c5d92..66641dd 100644 (file)
@@ -103,46 +103,248 @@ int PgGetMainMonitorPolicy(const int userId, int &mainMonitorPolicy) const;
 int PgUpdateMainMonitorPolicy(const int userId, const int mainMonitorPolicy);
 
 // DLP features
+
+/**
+ * @brief      add a list of leak logs to the database
+ *
+ * @param[in]  userId                  The ID of the user running the application 
+ * @param[in]  destination             The host which the data is to be sent to
+ * @param[in]  rawPacket               The data packet to be sent
+ * @param[in]  len                             The length of the packet data in bytes
+ * @param[in]  logList                 The std::list of leaks to be added.
+ *
+ * @return     An error code
+ * @since      Tizen 4.0
+ */
 int PgAddLeakLog(const int userId, const char *destination, const void *rawPacket, const size_t len, const std::list<leak_log_insert_data_s> &logList) const;
 
+/**
+ * @brief      get all logs from leaked packets.
+ *
+ * @param[in]  userId                  The ID of the user
+ * @param[out] logList                 The std::list of leaks returned
+ *
+ * @return     An error code
+ * @since      Tizen 4.0
+ */
 int PgForeachLeakLogs(const int userId, std::list<leak_log_get_data_s> &logList) const;
 
+/**
+ * @brief      get all logs from leaked packet made by given application.
+ *
+ * @param[in]  userId                  The ID of the user
+ * @param[in]  appName                 The name of the application
+ * @param[out] logList                 The std::list of leaks returned
+ *
+ * @return     An error code
+ * @since      Tizen 4.0
+ */
 int PgForeachLeakLogsByAppName(const int userId, const char *appName, std::list<leak_log_get_data_s> &logList) const;
 
+/**
+ * @brief      get all logs from leaked packet made for the given pattern category.
+ *
+ * @param[in]  userId                  The ID of the user
+ * @param[in]  category                The name of the category
+ * @param[out] logList                 The std::list of leaks returned
+ *
+ * @return     An error code
+ * @since      Tizen 4.0
+ */
 int PgForeachLeakLogsByCategory(const int userId, const char *category, std::list<leak_log_get_data_s> &logList) const;
 
+/**
+ * @brief      get the total leak count of each application as detected by DLP
+ *
+ * @param[in]  userId                  The ID of the user
+ * @param[out] logList                 The std::list of leaks returned
+ *
+ * @return     An error code
+ * @since      Tizen 4.0
+ */
 int PgForeachAppLeakCount(const int userId, std::list<leak_log_get_app_count_s> &logList) const;
 
+/**
+ * @brief      get the total leak count of each pattern category as detected by DLP
+ *
+ * @param[in]  userId                  The ID of the user
+ * @param[out] logList                 The std::list of leaks returned
+ *
+ * @return     An error code
+ * @since      Tizen 4.0
+ */
 int PgForeachCategoryLeakCount(const int userId, std::list<leak_log_get_category_count_s> &logList) const;
 
+/**
+ * @brief      get logs from leaked packets by timestamp range.
+ *
+ * @param[in]  userId                  The ID of the user
+ * @param[in]  start                   The start timestamp
+ * @param[in]  end                             The end timestamp
+ * @param[out] logList                 The std::list of leaks returned
+ *
+ * @return     An error code
+ * @since      Tizen 4.0
+ */
 int PgForeachLeakLogsByTimestamp(const int userId, const time_t start, const time_t end, std::list<leak_log_get_data_s> &logList) const;
 
+/**
+ * @brief      get all logs from leaked packet
+ *
+ * @param[in]  userId                  The ID of the user
+ * @param[in]  logId                   The ID number of the log
+ * @param[out] logDetail               The details of all leaks relating to the packet
+ *
+ * @return     An error code
+ * @since      Tizen 4.0
+ */
 int PgGetLeakLogDetails(int userId, int logId, leak_log_get_detail_data_s *logDetail) const;
 
+/**
+ * @brief      purge all logs from the leaks database for the specified user
+ *
+ * @param[in]  userId                  The ID of the user
+ *
+ * @return     An error code
+ * @since      Tizen 4.0
+ */
 int PgPurgeLeakLogs(const int userId) const;
 
+/**
+ * @brief      purge a list of leak logs from the database
+ *
+ * @param[in]  logId                   A std::list of log ID numbers to be removed
+ *
+ * @return     An error code
+ * @since      Tizen 4.0
+ */
 int PgPurgeLeakLogsByLogId(const std::list<int> &logId) const;
 
+/**
+ * @brief      set user DLP profile
+ *
+ * @param[in]  userId                  The ID of the user
+ * @param[in]  profile                 The new profile to be assigned
+ *
+ * @return     An error code
+ * @since      Tizen 4.0
+ */
 int PgSetDlpProfile(const int userId, const dlp_profile_s *profile) const;
 
+/**
+ * @brief      get user DLP profile
+ *
+ * @param[in]  userId                  The ID of the user
+ * @param[out] profile                 The current profile details for the specified user
+ *
+ * @return     An error code
+ * @since      Tizen 4.0
+ */
 int PgGetDlpProfile(const int userId, dlp_profile_s *profile) const;
 
+/**
+ * @brief      get the current parsing rules for the application
+ *
+ * @param[in]  userId                  The ID of the user
+ * @param[in]  pId                             The process ID of the application
+ * @param[out] currentRules    A std::list of rules for the user and application
+ *
+ * @note       The rules can be updated at any time while the application is running.
+ * @see                DlpRuleChangeNotification::addDlpClient()
+ * @return     An error code
+ * @since      Tizen 4.0
+ */
 int PgGetDlpCurrentRules(const int userId, const int pId, std::list<current_rules_s> &currentRules) const;
-
+/**
+ * @brief      add a custom DLP rule for user userId
+ *
+ * @param[in]  userId                  The ID of the user
+ * @param[in]  action                  The action type for the rule
+ * @param[in]  patternId               The ID of the pattern to search for
+ * @param[in]  ruleName                The name of the rule
+ * @param[in]  ruleDescription The description of the rule
+ * @param[in]  applicationId   The ID of the application to which to apply the rule (or NULL to apply to all applications)
+ *
+ * @return     An error code
+ * @since      Tizen 4.0
+ */
 int PgAddDlpCustomRule(int userId, PgDlpAction action, int patternId, const char *ruleName, const char *ruleDescription, const char *applicationId) const;
 
+/**
+ * @brief      update a custom DLP rule
+ *
+ * @param[in]  ruleId                  The ID of the rule
+ * @param[in]  action                  The action type for the rule
+ * @param[in]  patternId               The ID of the pattern to search for
+ * @param[in]  ruleName                The name of the rule
+ * @param[in]  ruleDescription The description of the rule
+ * @param[in]  applicationId   The ID of the application to which to apply the rule (or NULL to apply to all applications)
+ *
+ * @return     An error code
+ * @since      Tizen 4.0
+ */
 int PgUpdateDlpCustomRule(int ruleId, PgDlpAction action, int patternId, const char *ruleName, const char *ruleDescription, const char *applicationId) const;
 
+/**
+ * @brief      delete a custom DLP rule from the database
+ *
+ * @param[in]  ruleId                  The ID of the rule to be deleted
+ *
+ * @return     An error code
+ * @since      Tizen 4.0
+ */
 int PgDeleteDlpCustomRule(int ruleId) const;
 
+/**
+ * @brief      get all dlp rules from user userId, profile profile
+ *
+ * @param[in]  userId                  The user ID
+ * @param[in]  profile                 The profile
+ * @param[out] rules                   std:list of rules
+ *
+ * @return     the result of operation (ERRORCODE : success, ....)
+ */
 int PgForeachDlpRules(int userId, PgDlpProfile profile, std::list<get_custom_rule_s> &rules) const;
 
+/**
+ * @brief      add a new DLP pattern
+ *
+ * @param[in]  name                    Pattern name
+ * @param[in]  description             Pattern description
+ * @param[in]  category                Pattern category
+ * @param[in]  pattern                 The pattern to match
+ * @param[in]  type                    Pattern type (STRING, REGEX)
+ *
+ * @return     the result of operation (ERRORCODE : success, ....)
+ */
 int PgAddDlpPattern(const char *name, const char *description, const char *category, const char *pattern, PgDlpPatternType type) const;
 
+/**
+ * @brief      delete the specified pattern from the user's view (marked as DELETED, later purged)
+ *
+ * @param[in]  pattern_id              The pattern to be removed
+ *
+ * @return     the result of operation (ERRORCODE : success, ....)
+ */
 int PgDeleteDlpPattern(int pattern_id) const;
 
+/**
+ * @brief      get all patterns
+ *
+ * @param[out] patterns                std:list of patterns
+ *
+ * @return     the result of operation (ERRORCODE : success, ....)
+ */
 int PgForeachDlpPatterns(std::list<get_pattern_s> &patterns) const;
 
+/**
+ * @brief      get all categories
+ *
+ * @param[out] categories              std:list of categories
+ *
+ * @return     the result of operation (ERRORCODE : success, ....)
+ */
 int PgForeachDlpCategories(std::list<std::string> &categories) const;
 };
 
index 352288b..ca35d6b 100755 (executable)
@@ -16,7 +16,7 @@
 
 /**
  * @file       privacy_guard_client_internal.h
- * @brief      APIs for privacy-guard-client
+ * @brief      Internal API for privacy-guard-client
  */
 
 #ifndef _PRIVACY_GUARD_CLIENT_INTERNAL_H_
index 02e493a..04e4bc3 100644 (file)
  *    limitations under the License.
  */
 
+/**
+ * @file       DlpLogsManager.cpp
+ * @brief      Manages the packet parsing and logging of leaks for a DLP client
+ */
+
 #include "DlpLogsManager.h"
 #include "PrivacyGuardClient.h"
 #include "Utils.h"
@@ -85,7 +90,7 @@ DlpLogsManager::ParseAndLogLeakNow(leak_log_queue_entry_s &entry)
        DlpPacketParser pp;
        DlpPacketParserResultList results;
 
-       // parse the packet seting the results
+       // parse the packet setting the results
        pp.setRules(entry.rlist);
        res = pp.parsePacket(entry.mem, entry.len, results);
 
index 24082c1..e71e0c9 100644 (file)
  *    limitations under the License.
  */
 
+/**
+ * @file       DlpRulesManager.cpp
+ * @brief      Manages the packet parsing rules for a client
+ */
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -71,16 +76,23 @@ DlpRulesManager::NewRulesNotificationThread()
        char sem_name[sizeof(PRIVACY_SEM_INITVAL)+5];
        snprintf(sem_name, sizeof(PRIVACY_SEM_INITVAL)+5, PRIVACY_SEM_INITVAL, pid);
        mode_t umask_value = umask(0111);
-       sem_t *semaphore = sem_open(sem_name, O_CREAT | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO, 0);
-       if (semaphore == SEM_FAILED) {
-               PG_LOGE("errro unlink sem: %s - %s", sem_name, strerror_r(errno, buf, sizeof(buf)));
-               return NULL;
-       }
+       sem_t *semaphore = sem_open(sem_name,
+                                O_CREAT | O_EXCL,
+                                S_IRWXU |
+                                S_IRGRP | S_IWGRP |
+                                S_IROTH | S_IWOTH,
+                                0);
        umask(umask_value);
 
        // Get rules from server for the first time
        m_privacyGuardClient->PgGetDlpCurrentRules(uid, pid, m_currentRules);
 
+       if (semaphore == SEM_FAILED) {
+               PG_LOGE("errro unlink sem: %s - %s", sem_name, strerror_r(errno, buf, sizeof(buf)));
+               m_rulesMutex.unlock();
+               return NULL;
+       }
+
        // Removing semaphore reference
        if (sem_unlink(sem_name) < 0)
                PG_LOGE("errro unlink sem: %s - %s", sem_name, strerror_r(errno, buf, sizeof(buf)));
index 34d2b8d..bf1137a 100644 (file)
@@ -16,6 +16,7 @@
 
 /**
  * @file       privacy_guard_client.cpp
+ * @brief      API for privacy-guard-client (C / C++)
  */
 
 #include <string.h>
@@ -799,4 +800,4 @@ EXTERN_API int privacy_guard_client_validate_pattern(PgDlpPatternType type, cons
        }
 
        return PRIV_GUARD_ERROR_SUCCESS;
-}
\ No newline at end of file
+}
index 48668ba..63c8bc8 100755 (executable)
@@ -16,6 +16,9 @@
 
 /**
  * @file       SocketConnection.h
+ * @brief       This class implements an interface for generic read and write from the given socket.
+ * @throws      SocketConnectionException when read/write does not succeed or if any bad allocation
+ *             exception occurs during read.
  */
 
 #ifndef _SOCKETCONNECTION_H_
index 36710fb..fb2d45b 100755 (executable)
@@ -30,6 +30,7 @@
 #include <string>
 #include <unistd.h>
 #include <db-util.h>
+#include "privacy_guard_utils.h"
 
 // debug print /////////////////////////////////////////////
 
@@ -129,13 +130,4 @@ public:
        static int PgCheckAccess(void);
 };
 
-/**
- * @brief      Copy at most (dstsize - 1) bytes from string src to string dst, appending a terminating null byte.
- *
- * @param[in]   dst       a pointer to the string to be written to. Must be at least dstsize bytes in length.
- * @param[in]   src       a pointer to the string to be copied from.
- * @param[in]   dstsize   the maximum number of bytes to be copied.
- */
-extern "C" void pg_strlcpy(char *dst, const char *src, size_t dstsize);
-
 #endif //_UTILS_H_
diff --git a/common/inc/privacy_guard_utils.h b/common/inc/privacy_guard_utils.h
new file mode 100644 (file)
index 0000000..01e7298
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2013 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.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+/**
+ * @file       privacy_guard_utils.h
+ */
+
+ #ifndef _PRIVACY_GUARD_UTILS_H_
+ #define _PRIVACY_GUARD_UTILS_H_
+
+/**
+ * @brief      Copy at most (dstsize - 1) bytes from string src to string dst, appending a terminating null byte.
+ *
+ * @param[in]   dst       a pointer to the string to be written to. Must be at least dstsize bytes in length.
+ * @param[in]   src       a pointer to the string to be copied from.
+ * @param[in]   dstsize   the maximum number of bytes to be copied.
+ */
+ extern "C" void pg_strlcpy(char *dst, const char *src, size_t dstsize);
+ #endif //_PRIVACY_GUARD_UTILS_H_
\ No newline at end of file
similarity index 90%
rename from common/src/pg_strlcpy.c
rename to common/src/privacy_guard_utils.c
index 09b5200..fef577a 100644 (file)
@@ -15,7 +15,7 @@
  */
 
 /**
- * @file       pg_strlcpy.c
+ * @file       privacy_guard_utils.c
  * @brief      Provides a safe string copy function.
  */
 
@@ -31,7 +31,7 @@ void pg_strlcpy(char *dst, const char *src, size_t dstsize)
                return;
        }
        if (dstsize > 0) {
-               strncpy(dst, src, dstsize);
-               dst[dstsize] = '\0';
+               strncpy(dst, src, dstsize - 1);
+               dst[dstsize - 1] = '\0';
        }
 }
index 62a1b3c..6f62b09 100755 (executable)
@@ -16,7 +16,7 @@
 
 /**
  * @file       privacy_guard_client.h
- * @brief      APIs for privacy-guard-client
+ * @brief      API for privacy-guard-client (C / C++)
  */
 
 #ifndef _PRIVACY_GUARD_CLIENT_H_
@@ -369,7 +369,7 @@ EXTERN_API int privacy_guard_client_get_leak_log_detail(int user_id, int log_id,
 
 /**
  * @fn int privacy_guard_client_purge_leak_logs(const int user_id)
- * @brief purge all logs from leaked database
+ * @brief purge all logs from the leaks database for the specified user
  * @param[in] user_id                          The user ID
  *
  * @return the result of operation (ERRORCODE : success, ....)
@@ -378,7 +378,7 @@ EXTERN_API int privacy_guard_client_purge_leak_logs(const int user_id);
 
 /**
  * @fn int privacy_guard_client_purge_leak_logs_by_logid(const int user_id, const int[] log_id, const size_t log_id_size)
- * @brief purge all logs from leaked database by logid
+ * @brief purge all logs from the leaks database by logid
  * @param[in] user_id                          The user ID
  * @param[in] log_id                           The log IDs to be purged
  * @param[in] log_id_size                      Number of elements in the log_id array
index faab28c..d3037b1 100644 (file)
@@ -16,6 +16,7 @@
 
 /**
  * @file       privacy_guard_client_types.h
+ * @brief      common types for the privacy guard client (C / C++)
  */
 
 #ifndef _PRIVACY_GUARD_CLIENT_TYPES_H_
index 8c6785c..789e270 100644 (file)
@@ -16,7 +16,7 @@
 
 /**
  * @file       privacy_guard_dlp.h
- * @brief      APIs for privacy-guard-dlp
+ * @brief      API for privacy-guard-dlp (C / C++)
  */
 
 #ifndef _PRIVACY_GUARD_DLP_H_
index 1c88c2e..64e0671 100755 (executable)
@@ -54,7 +54,7 @@ SET(PRIVACY_GUARD_SERVER_SOURCES
        ${common_src_dir}/SocketConnection.cpp
        ${common_src_dir}/SocketStream.cpp
        ${common_src_dir}/PrivacyIdInfo.cpp
-       ${common_src_dir}/pg_strlcpy.c
+       ${common_src_dir}/privacy_guard_utils.c
        ${server_src_dir}/PrivacyGuardDb.cpp
        ${server_src_dir}/main.cpp
        ${server_src_dir}/SocketService.cpp
index 2f6eb48..432423d 100644 (file)
@@ -16,6 +16,7 @@
 
 /**
  * @file       DlpPrivacyInfoData.h
+ * @brief      Supplies setup and realtime data for the DLP subsystem
  */
 
 #ifndef _DLP_PRIVACYINFODATA_H_
@@ -50,9 +51,32 @@ class DlpPrivacyInfoData
 public:
        DlpPrivacyInfoData();
 
+       /**
+        * @brief replace template rules with actual rules to be sent to the client
+        * @param[in] userId                            The user ID
+        * @param[in] rulesIn                           A std::list of rules which may include templates
+        * @param[out] rulesOut                         A std::list of rules with templates replaced by actual values
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 3.0
+        */
        void replaceRuleTemplates(const int userId, std::list<current_rules_s> *rulesIn, std::list<current_rules_s> *rulesOut);
        static DlpPrivacyInfoData *getInstance();
+
+       /**
+        * @brief start the thread which returns real time updated data
+        *
+        * @return              true if the thread started without error
+        * @see stop()
+        * @since Tizen 3.0
+        */
        bool start(void);
+
+       /**
+        * @brief stop the thread which returns real time updated data
+        * @see start()
+        * @since Tizen 3.0
+        */
        void stop(void);
 
 private:
index 0e284d0..a121f0d 100644 (file)
@@ -16,6 +16,7 @@
 
 /**
  * @file       DlpRuleChangeNotification.h
+ * @brief      Functions for notifying clients when a rule may have changed.
  */
 
 #ifndef _DLP_RULECHANGENOTIFICATION_H_
@@ -36,7 +37,22 @@ private:
 
 public:
        static DlpRuleChangeNotification *getInstance(void);
+
+       /**
+        * @brief add a new client to list of clients to inform about rule changes
+        * @param[in] pId                       The process id of the client to be added
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 3.0
+        */
        int addDlpClient(int pId);
+
+       /**
+        * @brief send notification to all registered clients that a rule may have changed
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 3.0
+        */
        int notifyDlpClients(void);
 };
 
index 045630c..a637523 100755 (executable)
@@ -27,6 +27,7 @@
 #include <set>
 #include <mutex>
 #include <glib.h>
+#include "privacy_guard_utils.h"
 #include "ICommonDb.h"
 #include "privacy_guard_client_types.h"
 #include "PrivacyGuardTypes.h"
@@ -35,7 +36,7 @@ typedef enum {
        PRIV_GUARD_DLP_PATTERN_STATE_UNDELETABLE = 0, ///< for built-in patterns
        PRIV_GUARD_DLP_PATTERN_STATE_DELETABLE, ///< default for newly created patterns (can go to state in_use or state deleted)
        PRIV_GUARD_DLP_PATTERN_STATE_IN_USE, ///< pattern is attached to one or more rules, user cannot delete it (system will move to deleted when no longer used)
-       PRIV_GUARD_DLP_PATTERN_STATE_DELETED ///< pattern was deleted (can go to IN_USE if user re-creates it), will be deleted when no leaks point to it
+       PRIV_GUARD_DLP_PATTERN_STATE_DELETED ///< pattern was deleted (can go to DELETABLE if the user re-creates it), will be deleted when no leaks point to it
 } PgDlpPatternState;
 
 class PrivacyGuardDb:public ICommonDb
@@ -105,48 +106,225 @@ public:
        int PgDeleteMainMonitorPolicyByUserId(const int userId);
 
        // DLP features
-       int PgAddLeakLog(leak_log_insert_common_data_s &data, const std::list<leak_log_insert_data_s> &logList);
 
-       int PgForeachLeakLogs(const int userId, const char *appName, int category_id, std::list<leak_log_get_data_s> &logList);
+       /**
+        * @brief add a new leak to the database
+        * @param[in] data                              The common part of the leak log(s)
+        * @param[in] logList                           The detailed parts of the leak log(s)
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 4.0
+        */
+       int PgAddLeakLog(leak_log_insert_common_data_s &data, const std::list<leak_log_insert_data_s> &logList);
 
+       /**
+        * @brief generate a list of leak logs for the specified user, app and category
+        * @param[in] userId                            The user ID
+        * @param[in] appName                           Application name (or NULL)
+        * @param[in] categoryId                        The requested category (or 0 for all categories)
+        * @param[out] logList                          The list of results from the database
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 4.0
+        */
+       int PgForeachLeakLogs(const int userId, const char *appName, int categoryId, std::list<leak_log_get_data_s> &logList);
+
+       /**
+        * @brief generate a list of leak log totals by application
+        * @param[in] userId                            The user ID
+        * @param[out] logList                          The list of results from the database
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 4.0
+        */
        int PgForeachAppLeakCount(const int userId, std::list<leak_log_get_app_count_s> &logList);
 
+       /**
+        * @brief generate a list of leak log totals by category
+        * @param[in] userId                            The user ID
+        * @param[out] logList                          The list of results from the database
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 4.0
+        */
        int PgForeachCategoryLeakCount(const int userId, std::list<leak_log_get_category_count_s> &logList);
 
+       /**
+        * @brief generate a list of leak logs between two timestamps
+        * @param[in] userId                            The user ID
+        * @param[in] start                             The start timecode for the range
+        * @param[in] end                               The end timecode for the range
+        * @param[out] logList                          The list of results from the database
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 4.0
+        */
        int PgForeachLeakLogsByTimestamp(const int userId, const time_t start, const time_t end, std::list<leak_log_get_data_s> &logList);
 
+       /**
+        * @brief get details for a leak log
+        * @param[in] userId                            The user ID
+        * @param[in] logId                             The ID number of the leak
+        * @param[out] logDetail                        The list of results from the database
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 4.0
+        */
        int PgGetLeakLogDetails(int userId, int logId, leak_log_get_detail_data_s &logDetail);
 
+       /**
+        * @brief purge all leak logs from the database; remove unused patterns in the DELETED state
+        * @param[in] userId                            The user ID to purge leaks for
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 4.0
+        */
        int PgPurgeLeakLogs(const int userId);
 
+       /**
+        * @brief purge all leak logs older than specified days from the database
+        * @param[in] userId                            The user ID to purge leaks for
+        * @param[in] days                              The minimum number of rounded up days to delete
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 4.0
+        */
        int PgPurgeLeakLogsByDays(const int userId, int days);
 
+       /**
+        * @brief purge all leak logs from a list of log ID's
+        * @param[in] logId                             A std::list of log IDs to be purged from the database
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 4.0
+        */
        int PgPurgeLeakLogsByLogId(const std::list<int> &logId);
 
+       /**
+        * @brief set the DLP profile
+        * @param[in] userId                            The user ID to set the profile for
+        * @param[in] profile                           The profile to set
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 4.0
+        */
        int PgSetDlpProfile(const int userId, const dlp_profile_s &profile);
 
+       /**
+        * @brief get the DLP profile
+        * @param[in] userId                            The user ID to get the profile for
+        * @param[out] profile                          The profile which was retrieved
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 4.0
+        */
        int PgGetDlpProfile(const int userId, dlp_profile_s &profile);
 
+       /**
+        * @brief get the list of current rules
+        * @param[in] userId                            The user ID to get the rules for
+        * @param[in] AppId                             The application name (or empty string)
+        * @param[in] pId                               The process ID, to be added to the list of rule change notification clients
+        * @param[out] rules                            The rules which were retrieved
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 4.0
+        */
        int PgGetDlpCurrentRules(const int userId, const char *AppId, const int pId, std::list<current_rules_s> &rules);
 
+       /**
+        * @brief retrieve the list of email addresses for the specified user
+        * @param[in] userId                            The user ID to get the addresses for
+        * @param[out] emails                           The email addresses which were retrieved
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 4.0
+        */
        int PgGetAccountEmails(const int userId, std::set<std::string> &emails);
 
+       /**
+        * @brief add a new custom rule to the database
+        * @param[in] userId                            The user ID to add the rule for
+        * @param[in] rule                              Details of the rule to be added
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 4.0
+        */
        int PgAddDlpCustomRule(int userId, const custom_rule_s &rule);
 
+       /**
+        * @brief update a custom rule with new values
+        * @param[in] rule                              Details of the rule to be updated
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 4.0
+        */
        int PgUpdateDlpCustomRule(const custom_rule_s &rule);
 
+       /**
+        * @brief delete a custom rule from the database
+        * @param[in] ruleId                            The ID of the rule to be deleted
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 4.0
+        */
        int PgDeleteDlpCustomRule(int ruleId);
 
+       /**
+        * @brief generate a list of custom rules for the user
+        * @param[in] userId                            The user ID
+        * @param[out] rules                            The list of results from the database
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 4.0
+        */
        int PgForeachDlpCustomRules(int userId, std::list<get_custom_rule_s> &rules);
 
+       /**
+        * @brief generate a list of rules for the user / profile
+        * @param[in] userId                            The user ID
+        * @param[in] profile                           The profile type
+        * @param[out] rules                            The list of results from the database
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 4.0
+        */
        int PgForeachDlpRules(int userId, int profile, std::list<get_custom_rule_s> &rules);
 
+       /**
+        * @brief add a new pattern to the database
+        * @param[in] pattern                           The details of the pattern to add
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 4.0
+        */
        int PgAddDlpPattern(const pattern_s &pattern);
 
-       int PgDeleteDlpPattern(int pattern_id);
-
+       /**
+        * @brief delete a pattern from the database
+        * @param[in] patternId                         The ID of the pattern to be deleted (marked as DELETED, later purged)
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 4.0
+        */
+       int PgDeleteDlpPattern(int patternId);
+
+       /**
+        * @brief generate a list of patterns
+        * @param[out] patterns                         The list of patterns from the database
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 4.0
+        */
        int PgForeachDlpPatterns(std::list<get_pattern_s> &patterns);
 
+       /**
+        * @brief generate a list of categories
+        * @param[out] categories                       The list of categories from the database
+        *
+        * @return the result of operation (ERRORCODE : success, ....)
+        * @since Tizen 4.0
+        */
        int PgGetDlpCategories(std::list<std::string> &categories);
 };
 
index 55f36a1..cac730e 100755 (executable)
@@ -16,6 +16,7 @@
 
 /**
  * @file       PrivacyInfoService.h
+ * @brief      Server side connection to the socketServer
  */
 
 #ifndef _PRIVACYINFOSERVICE_H_
@@ -93,27 +94,159 @@ static void PgUpdateMonitorPolicy(SocketConnection *pConnector);
 static void PgGetMainMonitorPolicy(SocketConnection *pConnector);
 static void PgUpdateMainMonitorPolicy(SocketConnection *pConnector);
 static void PgDeleteAllLogs(SocketConnection *pConnector);
+
+/**
+ * @brief add a list of leak logs to the database
+ * @param[in] pConnector       The SocketConnection to / from the client
+ * @since Tizen 3.0
+ */
 static void PgAddLeakLog(SocketConnection *pConnector);
+
+ /**
+ * @brief get all logs from leaked packet made by given application.
+ * @param[in] pConnector       The SocketConnection to / from the client
+ * @since Tizen 3.0
+ */
 static void PgForeachLeakLogsByAppName(SocketConnection *pConnector);
+
+/**
+ * @brief get all logs from leaked packet made for the given pattern category.
+ * @param[in] pConnector       The SocketConnection to / from the client
+ * @since Tizen 3.0
+ */
 static void PgForeachLeakLogsByCategory(SocketConnection *pConnector);
+
+/**
+ * @brief get all logs from leaked packets.
+ * @param[in] pConnector       The SocketConnection to / from the client
+ * @since Tizen 3.0
+ */
 static void PgForeachLeakLogs(SocketConnection *pConnector);
+
+/**
+ * @brief get the total leak count of each application as detected by DLP
+ * @param[in] pConnector       The SocketConnection to / from the client
+ * @since Tizen 3.0
+ */
 static void PgForeachAppLeakCount(SocketConnection *pConnector);
+
+/**
+ * @brief get the total leak count of each pattern category as detected by DLP
+ * @param[in] pConnector       The SocketConnection to / from the client
+ * @since Tizen 3.0
+ */
 static void PgForeachCategoryLeakCount(SocketConnection *pConnector);
+
+/**
+ * @brief get logs from leaked packets by timestamp range.
+ * @param[in] pConnector       The SocketConnection to / from the client
+ * @since Tizen 3.0
+ */
 static void PgForeachLeakLogsByTimestamp(SocketConnection *pConnector);
+
+/**
+ * @brief get all logs from leaked packet
+ * @param[in] pConnector       The SocketConnection to / from the client
+ * @since Tizen 3.0
+ */
 static void PgGetLeakLogDetails(SocketConnection *pConnector);
+
+/**
+ * @brief purge all logs from the leaks database for a specified user
+ * @param[in] pConnector       The SocketConnection to / from the client
+ * @since Tizen 3.0
+ */
 static void PgPurgeLeakLogs(SocketConnection *pConnector);
+
+/**
+ * @brief purge a list of leak logs from the database
+ * @param[in] pConnector       The SocketConnection to / from the client
+ * @since Tizen 3.0
+ */
 static void PgPurgeLeakLogsByLogId(SocketConnection *pConnector);
+
+/**
+ * @brief get user DLP profile
+ * @param[in] pConnector       The SocketConnection to / from the client
+ * @since Tizen 3.0
+ */
 static void PgGetDlpProfile(SocketConnection *pConnector);
+
+/**
+ * @brief set user DLP profile
+ * @param[in] pConnector       The SocketConnection to / from the client
+ * @since Tizen 3.0
+ */
 static void PgSetDlpProfile(SocketConnection *pConnector);
+
+/**
+ * @brief get the current rules from the server for a specified client
+ * @param[in] pConnector       The SocketConnection to / from the client
+ * @since Tizen 3.0
+ */
 static void PgGetDlpCurrentRules(SocketConnection *pConnector);
+
+/**
+ * @brief add a custom DLP rule
+ * @param[in] pConnector       The SocketConnection to / from the client
+ * @since Tizen 3.0
+ */
 static void PgAddDlpCustomRule(SocketConnection *pConnector);
+
+/**
+ * @brief update a custom DLP rule
+ * @param[in] pConnector       The SocketConnection to / from the client
+ * @since Tizen 3.0
+ */
 static void PgUpdateDlpCustomRule(SocketConnection *pConnector);
+
+/**
+ * @brief delete a custom DLP rule
+ * @param[in] pConnector       The SocketConnection to / from the client
+ * @since Tizen 3.0
+ */
 static void PgDeleteDlpCustomRule(SocketConnection *pConnector);
+
+/**
+ * @brief return a list of rules
+ * @param[in] pConnector       The SocketConnection to / from the client
+ * @since Tizen 3.0
+ */
 static void PgForeachDlpCustomRules(SocketConnection *pConnector);
+
+/**
+ * @brief return a list of rules
+ * @param[in] pConnector       The SocketConnection to / from the client
+ * @since Tizen 3.0
+ */
 static void PgForeachDlpRules(SocketConnection *pConnector);
+
+/**
+ * @brief add a pattern to the database
+ * @param[in] pConnector       The SocketConnection to / from the client
+ * @since Tizen 3.0
+ */
 static void PgAddDlpPattern(SocketConnection* pConnector);
+
+/**
+ * @brief delete a pattern from the database
+ * @param[in] pConnector       The SocketConnection to / from the client
+ * @since Tizen 3.0
+ */
 static void PgDeleteDlpPattern(SocketConnection* pConnector);
+
+/**
+ * @brief return a list of all patterns
+ * @param[in] pConnector       The SocketConnection to / from the client
+ * @since Tizen 3.0
+ */
 static void PgForeachDlpPatterns(SocketConnection *pConnector);
+
+/**
+ * @brief return a list of all categories
+ * @param[in] pConnector       The SocketConnection to / from the client
+ * @since Tizen 3.0
+ */
 static void PgGetDlpCategories(SocketConnection *pConnector);
 };
 #endif // _PRIVACYINFOSERVICE_H_
index 782a493..02efe5c 100644 (file)
@@ -990,7 +990,7 @@ PrivacyGuardDb::PgForeachMonitorPolicyByPackageId(const int userId, const std::s
                }
                privacy_data_s p_data;
                memset(p_data.privacy_id, 0x0, LEN_PRIVACY_ID);
-               pg_strlcpy(p_data.privacy_id, tmp_data, strlen(tmp_data));
+               pg_strlcpy(p_data.privacy_id, tmp_data, LEN_PRIVACY_ID);
                p_data.monitor_policy = sqlite3_column_int(m_stmt, 1);
 
                privacyInfoList.push_back(p_data);
@@ -1150,8 +1150,8 @@ PrivacyGuardDb::prepareGlobalPackagePolicy(const int userId)
                package_privacy_data_s p_data;
                memset(p_data.package_id, 0x0, LEN_PACKAGE_ID);
                memset(p_data.privacy_id, 0x0, LEN_PRIVACY_ID);
-               pg_strlcpy(p_data.package_id, package_id, strlen(package_id));
-               pg_strlcpy(p_data.privacy_id, privacy_id, strlen(privacy_id));
+               pg_strlcpy(p_data.package_id, package_id, LEN_PACKAGE_ID);
+               pg_strlcpy(p_data.privacy_id, privacy_id, LEN_PRIVACY_ID);
                dataList.push_back(p_data);
        }
 
@@ -1253,7 +1253,7 @@ PrivacyGuardDb::PgForeachPackageInfoByPrivacyId(const int userId, const std::str
                }
                package_data_s p_data;
                memset(p_data.package_id, 0x0, LEN_PACKAGE_ID);
-               pg_strlcpy(p_data.package_id, tmp_data, strlen(tmp_data));
+               pg_strlcpy(p_data.package_id, tmp_data, LEN_PACKAGE_ID);
                p_data.monitor_policy = sqlite3_column_int(m_stmt, 1);
                PG_LOGD("## package_id[%s]", p_data.package_id);
                PG_LOGD("## monitor_policy[%d]", p_data.monitor_policy);
index 27e6e1c..7ccda80 100644 (file)
@@ -27,6 +27,7 @@
 #include "DlpPrivacyInfoData.h"
 #include "PrivacyGuardDb.h"
 #include "DlpRuleChangeNotification.h"
+#include "privacy_guard_utils.h"
 
 #define LEN_LOCATION     24
 
index 8f089c8..b0fcc37 100755 (executable)
@@ -22,6 +22,7 @@
 #include "DlpPrivacyInfoData.h"
 #include "PrivacyGuardDb.h"
 #include "Utils.h"
+#include "privacy_guard_utils.h"
 
 void
 PrivacyInfoService::PgAddPrivacyAccessLog(SocketConnection* pConnector)
index 59feed7..a62c055 100644 (file)
@@ -6,9 +6,9 @@ SET(TC1_NAME tc-privacy-guard)
 SET(TC2_NAME tc-dlp)
 SET(TC3_NAME tc-dlp-performance)
 
-SET(TC1_SRCS ${TC1_NAME}.c ${CMAKE_SOURCE_DIR}/common/src/pg_strlcpy.c)
-SET(TC2_SRCS ${TC2_NAME}.c ${CMAKE_SOURCE_DIR}/ahocorasick/ahocorasick.c ${CMAKE_SOURCE_DIR}/ahocorasick/node.c ${CMAKE_SOURCE_DIR}/common/src/pg_strlcpy.c)
-SET(TC3_SRCS ${TC3_NAME}.c ${CMAKE_SOURCE_DIR}/common/src/pg_strlcpy.c)
+SET(TC1_SRCS ${TC1_NAME}.c)
+SET(TC2_SRCS ${TC2_NAME}.c)
+SET(TC3_SRCS ${TC3_NAME}.c)
 
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/client/inc ${CMAKE_SOURCE_DIR}/common/inc ${CMAKE_SOURCE_DIR}/common/src)
 
@@ -23,14 +23,16 @@ ENDFOREACH(flag)
 SET(EXTRA_CXXFLAGS "${EXTRA_CFLAGS} -fPIC -Wall -Werror")
 SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
 
+SET(SOURCES ${CMAKE_SOURCE_DIR}/ahocorasick/ahocorasick.c ${CMAKE_SOURCE_DIR}/ahocorasick/node.c ${CMAKE_SOURCE_DIR}/common/src/privacy_guard_utils.c)
+
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall -fvisibility=hidden -D_WITH_SYSTEMD_")
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${PACKAGE_NAME_CFLAGS} -fPIE")
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
 SET(PC_LDFLAGS -lpcre)
 
-ADD_EXECUTABLE(${TC1_NAME} ${TC1_SRCS})
-ADD_EXECUTABLE(${TC2_NAME} ${TC2_SRCS})
-ADD_EXECUTABLE(${TC3_NAME} ${TC3_SRCS})
+ADD_EXECUTABLE(${TC1_NAME} ${TC1_SRCS} ${SOURCES})
+ADD_EXECUTABLE(${TC2_NAME} ${TC2_SRCS} ${SOURCES})
+ADD_EXECUTABLE(${TC3_NAME} ${TC3_SRCS} ${SOURCES})
 
 TARGET_LINK_LIBRARIES(${TC1_NAME} "privacy-guard-client")
 TARGET_LINK_LIBRARIES(${TC2_NAME} "privacy-guard-client")
index 9e11e15..ada4df5 100644 (file)
@@ -960,9 +960,9 @@ static void __test_privacy_guard_client_update_monitor_policy_02(void)
                        res = privacy_guard_client_update_monitor_policy(USER_ID_OWNER, package_id, PRIVACY_LOCATION, off);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                        memset(&data, 0x0, sizeof(TEST_DATA));
-                       pg_strlcpy(data.function_name, __FUNCTION__, strlen(__FUNCTION__));
-                       pg_strlcpy(data.privacy_id, PRIVACY_LOCATION, strlen(PRIVACY_LOCATION));
-                       pg_strlcpy(data.package_id, package_id, strlen(package_id));
+                       pg_strlcpy(data.function_name, __FUNCTION__, LEN_FUNCTION_NAME);
+                       pg_strlcpy(data.privacy_id, PRIVACY_LOCATION, LEN_PRIVACY_ID);
+                       pg_strlcpy(data.package_id, package_id, LEN_PACKAGE_ID);
                        res = privacy_guard_client_foreach_monitor_policy_by_package_id(USER_ID_OWNER, package_id, __monitor_policy_cb, &data);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                }
@@ -975,9 +975,9 @@ static void __test_privacy_guard_client_update_monitor_policy_02(void)
                        res = privacy_guard_client_update_monitor_policy(USER_ID_OWNER, package_id, PRIVACY_ACCOUNT, off);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                        memset(&data, 0x0, sizeof(TEST_DATA));
-                       pg_strlcpy(data.function_name, __FUNCTION__, strlen(__FUNCTION__));
-                       pg_strlcpy(data.privacy_id, PRIVACY_ACCOUNT, strlen(PRIVACY_ACCOUNT));
-                       pg_strlcpy(data.package_id, package_id, strlen(package_id));
+                       pg_strlcpy(data.function_name, __FUNCTION__, LEN_FUNCTION_NAME);
+                       pg_strlcpy(data.privacy_id, PRIVACY_ACCOUNT, LEN_PRIVACY_ID);
+                       pg_strlcpy(data.package_id, package_id, LEN_PACKAGE_ID);
                        res = privacy_guard_client_foreach_monitor_policy_by_package_id(USER_ID_OWNER, package_id, __monitor_policy_cb, &data);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                }
@@ -990,9 +990,9 @@ static void __test_privacy_guard_client_update_monitor_policy_02(void)
                        res = privacy_guard_client_update_monitor_policy(USER_ID_OWNER, package_id, PRIVACY_BOOKMARK, off);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                        memset(&data, 0x0, sizeof(TEST_DATA));
-                       pg_strlcpy(data.function_name, __FUNCTION__, strlen(__FUNCTION__));
-                       pg_strlcpy(data.privacy_id, PRIVACY_BOOKMARK, strlen(PRIVACY_BOOKMARK));
-                       pg_strlcpy(data.package_id, package_id, strlen(package_id));
+                       pg_strlcpy(data.function_name, __FUNCTION__, LEN_FUNCTION_NAME);
+                       pg_strlcpy(data.privacy_id, PRIVACY_BOOKMARK, LEN_PRIVACY_ID);
+                       pg_strlcpy(data.package_id, package_id, LEN_PACKAGE_ID);
                        res = privacy_guard_client_foreach_monitor_policy_by_package_id(USER_ID_OWNER, package_id, __monitor_policy_cb, &data);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                }
@@ -1005,9 +1005,9 @@ static void __test_privacy_guard_client_update_monitor_policy_02(void)
                        res = privacy_guard_client_update_monitor_policy(USER_ID_OWNER, package_id, PRIVACY_CALENDAR, off);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                        memset(&data, 0x0, sizeof(TEST_DATA));
-                       pg_strlcpy(data.function_name, __FUNCTION__, strlen(__FUNCTION__));
-                       pg_strlcpy(data.privacy_id, PRIVACY_CALENDAR, strlen(PRIVACY_CALENDAR));
-                       pg_strlcpy(data.package_id, package_id, strlen(package_id));
+                       pg_strlcpy(data.function_name, __FUNCTION__, LEN_FUNCTION_NAME);
+                       pg_strlcpy(data.privacy_id, PRIVACY_CALENDAR, LEN_PRIVACY_ID);
+                       pg_strlcpy(data.package_id, package_id, LEN_PACKAGE_ID);
                        res = privacy_guard_client_foreach_monitor_policy_by_package_id(USER_ID_OWNER, package_id, __monitor_policy_cb, &data);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                }
@@ -1020,9 +1020,9 @@ static void __test_privacy_guard_client_update_monitor_policy_02(void)
                        res = privacy_guard_client_update_monitor_policy(USER_ID_OWNER, package_id, PRIVACY_CALL, off);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                        memset(&data, 0x0, sizeof(TEST_DATA));
-                       pg_strlcpy(data.function_name, __FUNCTION__, strlen(__FUNCTION__));
-                       pg_strlcpy(data.privacy_id, PRIVACY_CALL, strlen(PRIVACY_CALL));
-                       pg_strlcpy(data.package_id, package_id, strlen(package_id));
+                       pg_strlcpy(data.function_name, __FUNCTION__, LEN_FUNCTION_NAME);
+                       pg_strlcpy(data.privacy_id, PRIVACY_CALL, LEN_PRIVACY_ID);
+                       pg_strlcpy(data.package_id, package_id, LEN_PACKAGE_ID);
                        res = privacy_guard_client_foreach_monitor_policy_by_package_id(USER_ID_OWNER, package_id, __monitor_policy_cb, &data);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                }
@@ -1035,9 +1035,9 @@ static void __test_privacy_guard_client_update_monitor_policy_02(void)
                        res = privacy_guard_client_update_monitor_policy(USER_ID_OWNER, package_id, PRIVACY_USERHISTORY, off);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                        memset(&data, 0x0, sizeof(TEST_DATA));
-                       pg_strlcpy(data.function_name, __FUNCTION__, strlen(__FUNCTION__));
-                       pg_strlcpy(data.privacy_id, PRIVACY_USERHISTORY, strlen(PRIVACY_USERHISTORY));
-                       pg_strlcpy(data.package_id, package_id, strlen(package_id));
+                       pg_strlcpy(data.function_name, __FUNCTION__, LEN_FUNCTION_NAME);
+                       pg_strlcpy(data.privacy_id, PRIVACY_USERHISTORY, LEN_PRIVACY_ID);
+                       pg_strlcpy(data.package_id, package_id, LEN_PACKAGE_ID);
                        res = privacy_guard_client_foreach_monitor_policy_by_package_id(USER_ID_OWNER, package_id, __monitor_policy_cb, &data);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                }
@@ -1050,9 +1050,9 @@ static void __test_privacy_guard_client_update_monitor_policy_02(void)
                        res = privacy_guard_client_update_monitor_policy(USER_ID_OWNER, package_id, PRIVACY_CAMERA, off);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                        memset(&data, 0x0, sizeof(TEST_DATA));
-                       pg_strlcpy(data.function_name, __FUNCTION__, strlen(__FUNCTION__));
-                       pg_strlcpy(data.privacy_id, PRIVACY_CAMERA, strlen(PRIVACY_CAMERA));
-                       pg_strlcpy(data.package_id, package_id, strlen(package_id));
+                       pg_strlcpy(data.function_name, __FUNCTION__, LEN_FUNCTION_NAME);
+                       pg_strlcpy(data.privacy_id, PRIVACY_CAMERA, LEN_PRIVACY_ID);
+                       pg_strlcpy(data.package_id, package_id, LEN_PACKAGE_ID);
                        res = privacy_guard_client_foreach_monitor_policy_by_package_id(USER_ID_OWNER, package_id, __monitor_policy_cb, &data);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                }
@@ -1065,9 +1065,9 @@ static void __test_privacy_guard_client_update_monitor_policy_02(void)
                        res = privacy_guard_client_update_monitor_policy(USER_ID_OWNER, package_id, PRIVACY_CONTACTS, off);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                        memset(&data, 0x0, sizeof(TEST_DATA));
-                       pg_strlcpy(data.function_name, __FUNCTION__, strlen(__FUNCTION__));
-                       pg_strlcpy(data.privacy_id, PRIVACY_CONTACTS, strlen(PRIVACY_CONTACTS));
-                       pg_strlcpy(data.package_id, package_id, strlen(package_id));
+                       pg_strlcpy(data.function_name, __FUNCTION__, LEN_FUNCTION_NAME);
+                       pg_strlcpy(data.privacy_id, PRIVACY_CONTACTS, LEN_PRIVACY_ID);
+                       pg_strlcpy(data.package_id, package_id, LEN_PACKAGE_ID);
                        res = privacy_guard_client_foreach_monitor_policy_by_package_id(USER_ID_OWNER, package_id, __monitor_policy_cb, &data);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                }
@@ -1080,9 +1080,9 @@ static void __test_privacy_guard_client_update_monitor_policy_02(void)
                        res = privacy_guard_client_update_monitor_policy(USER_ID_OWNER, package_id, PRIVACY_MESSAGE, off);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                        memset(&data, 0x0, sizeof(TEST_DATA));
-                       pg_strlcpy(data.function_name, __FUNCTION__, strlen(__FUNCTION__));
-                       pg_strlcpy(data.privacy_id, PRIVACY_MESSAGE, strlen(PRIVACY_MESSAGE));
-                       pg_strlcpy(data.package_id, package_id, strlen(package_id));
+                       pg_strlcpy(data.function_name, __FUNCTION__, LEN_FUNCTION_NAME);
+                       pg_strlcpy(data.privacy_id, PRIVACY_MESSAGE, LEN_PRIVACY_ID);
+                       pg_strlcpy(data.package_id, package_id, LEN_PACKAGE_ID);
                        res = privacy_guard_client_foreach_monitor_policy_by_package_id(USER_ID_OWNER, package_id, __monitor_policy_cb, &data);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                }
@@ -1095,9 +1095,9 @@ static void __test_privacy_guard_client_update_monitor_policy_02(void)
                        res = privacy_guard_client_update_monitor_policy(USER_ID_OWNER, package_id, PRIVACY_MICROPHONE, off);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                        memset(&data, 0x0, sizeof(TEST_DATA));
-                       pg_strlcpy(data.function_name, __FUNCTION__, strlen(__FUNCTION__));
-                       pg_strlcpy(data.privacy_id, PRIVACY_MICROPHONE, strlen(PRIVACY_MICROPHONE));
-                       pg_strlcpy(data.package_id, package_id, strlen(package_id));
+                       pg_strlcpy(data.function_name, __FUNCTION__, LEN_FUNCTION_NAME);
+                       pg_strlcpy(data.privacy_id, PRIVACY_MICROPHONE, LEN_PRIVACY_ID);
+                       pg_strlcpy(data.package_id, package_id, LEN_PACKAGE_ID);
                        res = privacy_guard_client_foreach_monitor_policy_by_package_id(USER_ID_OWNER, package_id, __monitor_policy_cb, &data);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                }
@@ -1110,9 +1110,9 @@ static void __test_privacy_guard_client_update_monitor_policy_02(void)
                        res = privacy_guard_client_update_monitor_policy(USER_ID_OWNER, package_id, PRIVACY_SENSOR, off);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                        memset(&data, 0x0, sizeof(TEST_DATA));
-                       pg_strlcpy(data.function_name, __FUNCTION__, strlen(__FUNCTION__));
-                       pg_strlcpy(data.privacy_id, PRIVACY_SENSOR,  strlen(PRIVACY_SENSOR));
-                       pg_strlcpy(data.package_id, package_id, strlen(package_id));
+                       pg_strlcpy(data.function_name, __FUNCTION__, LEN_FUNCTION_NAME);
+                       pg_strlcpy(data.privacy_id, PRIVACY_SENSOR,  LEN_PRIVACY_ID);
+                       pg_strlcpy(data.package_id, package_id, LEN_PACKAGE_ID);
                        res = privacy_guard_client_foreach_monitor_policy_by_package_id(USER_ID_OWNER, package_id, __monitor_policy_cb, &data);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                }
@@ -1176,9 +1176,9 @@ static void __test_privacy_guard_client_foreach_monitor_policy_by_package_id_02(
                char *package_id = (char*)g_list_nth_data(package_list_using_location, i);
                if (package_id) {
                        memset(&data, 0x0, sizeof(TEST_DATA));
-                       pg_strlcpy(data.function_name, __FUNCTION__, strlen(__FUNCTION__));
-                       pg_strlcpy(data.privacy_id, PRIVACY_LOCATION, strlen(PRIVACY_LOCATION));
-                       pg_strlcpy(data.package_id, package_id, strlen(package_id));
+                       pg_strlcpy(data.function_name, __FUNCTION__, LEN_FUNCTION_NAME);
+                       pg_strlcpy(data.privacy_id, PRIVACY_LOCATION, LEN_PRIVACY_ID);
+                       pg_strlcpy(data.package_id, package_id, LEN_PACKAGE_ID);
                        res = privacy_guard_client_foreach_monitor_policy_by_package_id(USER_ID_OWNER, package_id, __monitor_policy_cb, &data);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                }
@@ -1189,9 +1189,9 @@ static void __test_privacy_guard_client_foreach_monitor_policy_by_package_id_02(
                char *package_id = (char*)g_list_nth_data(package_list_using_account, i);
                if (package_id) {
                        memset(&data, 0x0, sizeof(TEST_DATA));
-                       pg_strlcpy(data.function_name, __FUNCTION__, strlen(__FUNCTION__));
-                       pg_strlcpy(data.privacy_id, PRIVACY_ACCOUNT, strlen(PRIVACY_ACCOUNT));
-                       pg_strlcpy(data.package_id, package_id, strlen(package_id));
+                       pg_strlcpy(data.function_name, __FUNCTION__, LEN_FUNCTION_NAME);
+                       pg_strlcpy(data.privacy_id, PRIVACY_ACCOUNT, LEN_PRIVACY_ID);
+                       pg_strlcpy(data.package_id, package_id, LEN_PACKAGE_ID);
                        res = privacy_guard_client_foreach_monitor_policy_by_package_id(USER_ID_OWNER, package_id, __monitor_policy_cb, &data);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                }
@@ -1202,9 +1202,9 @@ static void __test_privacy_guard_client_foreach_monitor_policy_by_package_id_02(
                char *package_id = (char*)g_list_nth_data(package_list_using_bookmark, i);
                if (package_id) {
                        memset(&data, 0x0, sizeof(TEST_DATA));
-                       pg_strlcpy(data.function_name, __FUNCTION__, strlen(__FUNCTION__));
-                       pg_strlcpy(data.privacy_id, PRIVACY_BOOKMARK, strlen(PRIVACY_BOOKMARK));
-                       pg_strlcpy(data.package_id, package_id, strlen(package_id));
+                       pg_strlcpy(data.function_name, __FUNCTION__, LEN_FUNCTION_NAME);
+                       pg_strlcpy(data.privacy_id, PRIVACY_BOOKMARK, LEN_PRIVACY_ID);
+                       pg_strlcpy(data.package_id, package_id, LEN_PACKAGE_ID);
                        res = privacy_guard_client_foreach_monitor_policy_by_package_id(USER_ID_OWNER, package_id, __monitor_policy_cb, &data);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                }
@@ -1215,9 +1215,9 @@ static void __test_privacy_guard_client_foreach_monitor_policy_by_package_id_02(
                char *package_id = (char*)g_list_nth_data(package_list_using_calendar, i);
                if (package_id) {
                        memset(&data, 0x0, sizeof(TEST_DATA));
-                       pg_strlcpy(data.function_name, __FUNCTION__, strlen(__FUNCTION__));
-                       pg_strlcpy(data.privacy_id, PRIVACY_CALENDAR, strlen(PRIVACY_CALENDAR));
-                       pg_strlcpy(data.package_id, package_id, strlen(package_id));
+                       pg_strlcpy(data.function_name, __FUNCTION__, LEN_FUNCTION_NAME);
+                       pg_strlcpy(data.privacy_id, PRIVACY_CALENDAR, LEN_PRIVACY_ID);
+                       pg_strlcpy(data.package_id, package_id, LEN_PACKAGE_ID);
                        res = privacy_guard_client_foreach_monitor_policy_by_package_id(USER_ID_OWNER, package_id, __monitor_policy_cb, &data);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                }
@@ -1228,9 +1228,9 @@ static void __test_privacy_guard_client_foreach_monitor_policy_by_package_id_02(
                char *package_id = (char*)g_list_nth_data(package_list_using_call, i);
                if (package_id) {
                        memset(&data, 0x0, sizeof(TEST_DATA));
-                       pg_strlcpy(data.function_name, __FUNCTION__, strlen(__FUNCTION__));
-                       pg_strlcpy(data.privacy_id, PRIVACY_CALL, strlen(PRIVACY_CALL));
-                       pg_strlcpy(data.package_id, package_id, strlen(package_id));
+                       pg_strlcpy(data.function_name, __FUNCTION__, LEN_FUNCTION_NAME);
+                       pg_strlcpy(data.privacy_id, PRIVACY_CALL, LEN_PRIVACY_ID);
+                       pg_strlcpy(data.package_id, package_id, LEN_PACKAGE_ID);
                        res = privacy_guard_client_foreach_monitor_policy_by_package_id(USER_ID_OWNER, package_id, __monitor_policy_cb, &data);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                }
@@ -1241,9 +1241,9 @@ static void __test_privacy_guard_client_foreach_monitor_policy_by_package_id_02(
                char *package_id = (char*)g_list_nth_data(package_list_using_userhistory, i);
                if (package_id) {
                        memset(&data, 0x0, sizeof(TEST_DATA));
-                       pg_strlcpy(data.function_name, __FUNCTION__, strlen(__FUNCTION__));
-                       pg_strlcpy(data.privacy_id, PRIVACY_USERHISTORY, strlen(PRIVACY_USERHISTORY));
-                       pg_strlcpy(data.package_id, package_id, strlen(package_id));
+                       pg_strlcpy(data.function_name, __FUNCTION__, LEN_FUNCTION_NAME);
+                       pg_strlcpy(data.privacy_id, PRIVACY_USERHISTORY, LEN_PRIVACY_ID);
+                       pg_strlcpy(data.package_id, package_id, LEN_PACKAGE_ID);
                        res = privacy_guard_client_foreach_monitor_policy_by_package_id(USER_ID_OWNER, package_id, __monitor_policy_cb, &data);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                }
@@ -1254,9 +1254,9 @@ static void __test_privacy_guard_client_foreach_monitor_policy_by_package_id_02(
                char *package_id = (char*)g_list_nth_data(package_list_using_camera, i);
                if (package_id) {
                        memset(&data, 0x0, sizeof(TEST_DATA));
-                       pg_strlcpy(data.function_name, __FUNCTION__, strlen(__FUNCTION__));
-                       pg_strlcpy(data.privacy_id, PRIVACY_CAMERA, strlen(PRIVACY_CAMERA));
-                       pg_strlcpy(data.package_id, package_id, strlen(package_id));
+                       pg_strlcpy(data.function_name, __FUNCTION__, LEN_FUNCTION_NAME);
+                       pg_strlcpy(data.privacy_id, PRIVACY_CAMERA, LEN_PRIVACY_ID);
+                       pg_strlcpy(data.package_id, package_id, LEN_PACKAGE_ID);
                        res = privacy_guard_client_foreach_monitor_policy_by_package_id(USER_ID_OWNER, package_id, __monitor_policy_cb, &data);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                }
@@ -1267,9 +1267,9 @@ static void __test_privacy_guard_client_foreach_monitor_policy_by_package_id_02(
                char *package_id = (char*)g_list_nth_data(package_list_using_contacts, i);
                if (package_id) {
                        memset(&data, 0x0, sizeof(TEST_DATA));
-                       pg_strlcpy(data.function_name, __FUNCTION__, strlen(__FUNCTION__));
-                       pg_strlcpy(data.privacy_id, PRIVACY_CONTACTS, strlen(PRIVACY_CONTACTS));
-                       pg_strlcpy(data.package_id, package_id, strlen(package_id));
+                       pg_strlcpy(data.function_name, __FUNCTION__, LEN_FUNCTION_NAME);
+                       pg_strlcpy(data.privacy_id, PRIVACY_CONTACTS, LEN_PRIVACY_ID);
+                       pg_strlcpy(data.package_id, package_id, LEN_PACKAGE_ID);
                        res = privacy_guard_client_foreach_monitor_policy_by_package_id(USER_ID_OWNER, package_id, __monitor_policy_cb, &data);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                }
@@ -1280,9 +1280,9 @@ static void __test_privacy_guard_client_foreach_monitor_policy_by_package_id_02(
                char *package_id = (char*)g_list_nth_data(package_list_using_message, i);
                if (package_id) {
                        memset(&data, 0x0, sizeof(TEST_DATA));
-                       pg_strlcpy(data.function_name, __FUNCTION__, strlen(__FUNCTION__));
-                       pg_strlcpy(data.privacy_id, PRIVACY_MESSAGE, strlen(PRIVACY_MESSAGE));
-                       pg_strlcpy(data.package_id, package_id, strlen(package_id));
+                       pg_strlcpy(data.function_name, __FUNCTION__, LEN_FUNCTION_NAME);
+                       pg_strlcpy(data.privacy_id, PRIVACY_MESSAGE, LEN_PRIVACY_ID);
+                       pg_strlcpy(data.package_id, package_id, LEN_PACKAGE_ID);
                        res = privacy_guard_client_foreach_monitor_policy_by_package_id(USER_ID_OWNER, package_id, __monitor_policy_cb, &data);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                }
@@ -1293,9 +1293,9 @@ static void __test_privacy_guard_client_foreach_monitor_policy_by_package_id_02(
                char *package_id = (char*)g_list_nth_data(package_list_using_microphone, i);
                if (package_id) {
                        memset(&data, 0x0, sizeof(TEST_DATA));
-                       pg_strlcpy(data.function_name, __FUNCTION__, strlen(__FUNCTION__));
-                       pg_strlcpy(data.privacy_id, PRIVACY_MICROPHONE, strlen(PRIVACY_MICROPHONE));
-                       pg_strlcpy(data.package_id, package_id, strlen(package_id));
+                       pg_strlcpy(data.function_name, __FUNCTION__, LEN_FUNCTION_NAME);
+                       pg_strlcpy(data.privacy_id, PRIVACY_MICROPHONE, LEN_PRIVACY_ID);
+                       pg_strlcpy(data.package_id, package_id, LEN_PACKAGE_ID);
                        res = privacy_guard_client_foreach_monitor_policy_by_package_id(USER_ID_OWNER, package_id, __monitor_policy_cb, &data);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                }
@@ -1306,9 +1306,9 @@ static void __test_privacy_guard_client_foreach_monitor_policy_by_package_id_02(
                char *package_id = (char*)g_list_nth_data(package_list_using_sensor, i);
                if (package_id) {
                        memset(&data, 0x0, sizeof(TEST_DATA));
-                       pg_strlcpy(data.function_name, __FUNCTION__, strlen(__FUNCTION__));
-                       pg_strlcpy(data.privacy_id, PRIVACY_SENSOR, strlen(PRIVACY_SENSOR));
-                       pg_strlcpy(data.package_id, package_id, strlen(package_id));
+                       pg_strlcpy(data.function_name, __FUNCTION__, LEN_FUNCTION_NAME);
+                       pg_strlcpy(data.privacy_id, PRIVACY_SENSOR, LEN_PRIVACY_ID);
+                       pg_strlcpy(data.package_id, package_id, LEN_PACKAGE_ID);
                        res = privacy_guard_client_foreach_monitor_policy_by_package_id(USER_ID_OWNER, package_id, __monitor_policy_cb, &data);
                        __check_result_error_code(PRIV_GUARD_ERROR_SUCCESS, res, __LINE__);
                }